Re: read from standard input

2009-12-04 Thread Chris Rebert
> On Sat, Dec 5, 2009 at 11:54 AM, Chris Rebert wrote: >> >> On Fri, Dec 4, 2009 at 9:37 PM, Siva B wrote: >> > Hi all, >> > >> > I wrote a program to read some data through standard input and write in >> > a >> > file. >> > the following code works fine in linux. >> > but its giving ArgumentErro

Re: editor with autocompletion

2009-12-04 Thread Siva B
Hi All, Thanks for your reply. What I want is An Editor which can support Dynamic Languages with Autocomplete. I have my own language with some file extension (for ex: *.fs ) I can add few keywords to editor, it should support autocomplte. thats what my idea. plz send me pointers (good if it is

Re: read from standard input

2009-12-04 Thread Siva B
Hi Chris, Thanks for you reply. The error log is here for my above program in windows: Traceback (most recent call last): File "C:\Documents and Settings\user\Desktop\t1.py", line 3, in orig_source = sys.stdin.read() AttributeError: read Regards, Siva On Sat, Dec 5, 2009 at 11:54 AM, Chr

Re: read from standard input

2009-12-04 Thread Chris Rebert
On Fri, Dec 4, 2009 at 9:37 PM, Siva B wrote: > Hi all, > > I wrote a program to read some data through standard input and write in a > file. > the following code works fine in linux. > but its giving ArgumentError in windows. There's no such error in Python; you're thinking of Ruby. Unless you g

read from standard input

2009-12-04 Thread Siva B
Hi all, I wrote a program to read some data through standard input and write in a file. the following code works fine in linux. but its giving ArgumentError in windows. Code: import sys orig_source = sys.stdin.read() file=open('data.txt','w') file.write(orig_source) file.close() please post s

Re: How to timeout when waiting for raw_input from user ?

2009-12-04 Thread Paul Rubin
northof40 writes: > I'm thinking of some logic where a raw_input call is executed and then > if more than X seconds elapses before the prompt is replied to the > process writes a message "Sorry too slow" (or similar). The simplest way to do this is with the alarm function and a signal handler. S

Re: python bijection

2009-12-04 Thread Steven D'Aprano
On Sat, 05 Dec 2009 11:42:15 +1100, Lie Ryan wrote: > I think this could be an interpretation of the Zen: > > Simple is better than complex. > Complex is better than complicated. > > can be read as: > List is better than Tree Because O(N) searches are better than O(log N) searches. Not. How ab

good code to study

2009-12-04 Thread Michael
I want to improve my knowledge of Python (note: I'm still on 2.5 or 2.6) by studying good existing code, especially GUI programs. Any suggestions? I'm looking at the eric source code now, for starters. Thanks, Mike -- http://mail.python.org/mailman/listinfo/python-list

Re: Can't print Chinese to HTTP

2009-12-04 Thread Gnarlodious
On Dec 1, 3:06 pm, Terry Reedy wrote: > def print(s): return sys.stdout.buffer.write(s.encode('utf-8')) Here is a better solution that lets me send any string to the function: def print(html): return sys.stdout.buffer.write(("Content-type:text/ plain;charset=utf-8\n\n"+html).encode('utf-8')) Why

Re: Got a single octet from socket, what to do ?

2009-12-04 Thread mudit tuli
Stephen, thanks a lot for the reply. This worked for me. I had a look at the struct module earlier but ignored it due to lack of examples, I'll look more into it. Mudit On Sat, Dec 5, 2009 at 8:17 AM, Stephen Hansen wrote: > On Fri, Dec 4, 2009 at 6:39 PM, mudit tuli wrote: > >> I am very new t

Re: python bijection

2009-12-04 Thread geremy condra
On Fri, Dec 4, 2009 at 8:38 PM, Carl Banks wrote: > On Dec 4, 4:42 pm, Lie Ryan wrote: >> On 12/5/2009 9:41 AM, Carl Banks wrote: >> >> >> >> >> >> > On Dec 4, 12:46 pm, geremy condra  wrote: >> > more common than full-blown graph package). >> >> Sure, its a tree, which is also a graph. In this c

Re: Can't print Chinese to HTTP

2009-12-04 Thread Gnarlodious
On Dec 2, 11:58 pm, Dennis Lee Bieber wrote: >         Have you tried > >         sys.stdout.write("Content-type:text/plain;charset=utf-8\r\n\r\n") Yes I tried that when it was suggested, to no avail. All I get is "Internal server error". All I can imagine is that there is no "sys.stdout.write" i

good code to study

2009-12-04 Thread Michael
I want to improve my knowledge of Python (note: I'm still on 2.5 or 2.6) by studying good existing code, especially GUI programs. Any suggestions? I'm looking at the eric source code now, for starters. Thanks, Mike -- http://mail.python.org/mailman/listinfo/python-list

Re: Got a single octet from socket, what to do ?

2009-12-04 Thread Stephen Hansen
On Fri, Dec 4, 2009 at 6:39 PM, mudit tuli wrote: > I am very new to Python and started getting to know socket programming > recently. > Made a socket server, which receives a "Single Octet"(treated as a single > 8-bit integer field) from a client. > But I am not sure what to do with this "Single

Got a single octet from socket, what to do ?

2009-12-04 Thread mudit tuli
I am very new to Python and started getting to know socket programming recently. Made a socket server, which receives a "Single Octet"(treated as a single 8-bit integer field) from a client. But I am not sure what to do with this "Single Octet" and how to decode it into a long integer, so that I ca

Re: subprocess kill

2009-12-04 Thread Carl Banks
On Dec 4, 3:44 pm, luca72 wrote: > On 5 Dic, 00:14, luca72 wrote: > > > > > > > On 5 Dic, 00:03, luca72 wrote: > > > > On 4 Dic, 23:23, Mike Driscoll wrote: > > > > > On Dec 4, 3:50 pm, luca72 wrote: > > > > > > Hello i'm using subprocess in this way: > > > > > self.luca = subprocess.Popen(['/

Re: [distutils] Install script under a different name

2009-12-04 Thread Lie Ryan
On 12/5/2009 11:34 AM, Nikolaus Rath wrote: Hello, All my Python files have extension .py. However, I would like to install scripts that are meant to be called by the user without the suffix, i.e. the file scripts/doit.py should end up as /usr/bin/doit. Apparently the scripts= option of the set

Re: python bijection

2009-12-04 Thread Lie Ryan
On 12/5/2009 12:38 PM, geremy condra wrote: Where a list will do, use a list- duh. But when you need a graph, you shouldn't have to homebrew an implementation any more than you should have to homebrew an odict or named tuple, both of which are substantially easier to get right than a graph is.

Re: How to timeout when waiting for raw_input from user ?

2009-12-04 Thread Maxim Khitrov
On Fri, Dec 4, 2009 at 6:55 PM, northof40 wrote: > On Dec 5, 12:52 pm, northof40 wrote: >> Hi - I'm writing a *very* simple program for my kids. It asks the user >> to give it the answer to a maths question and says "right" or "wrong" >> >> They now want a timed version where they would only get

Re: python bijection

2009-12-04 Thread Carl Banks
On Dec 4, 4:42 pm, Lie Ryan wrote: > On 12/5/2009 9:41 AM, Carl Banks wrote: > > > > > > > On Dec 4, 12:46 pm, geremy condra  wrote: > > more common than full-blown graph package). > >> Sure, its a tree, which is also a graph. In this case it looks to > >> me more like a directed acyclic graph tha

Re: python bijection

2009-12-04 Thread geremy condra
On Fri, Dec 4, 2009 at 7:42 PM, Lie Ryan wrote: > On 12/5/2009 9:41 AM, Carl Banks wrote: >> >> On Dec 4, 12:46 pm, geremy condra  wrote: >> more common than full-blown graph package). >>> >>> Sure, its a tree, which is also a graph. In this case it looks to >>> me more like a directed acyclic gra

Re: python bijection

2009-12-04 Thread geremy condra
On Fri, Dec 4, 2009 at 5:41 PM, Carl Banks wrote: > On Dec 4, 12:46 pm, geremy condra wrote: > more common than full-blown graph package). >> Sure, its a tree, which is also a graph. In this case it looks to >> me more like a directed acyclic graph than anything, but its >> pretty much just seman

package_data question

2009-12-04 Thread Miki
Hello All, I'm trying to add package_data from outside the package directory. The current project looks like: . |-- __init__.py |-- a | `-- src | `-- py | `-- __init__.py |-- b | `-- src | `-- py | `-- __init__.py |-- c | `-- src | `-- py | `--

[distutils] Install script under a different name

2009-12-04 Thread Nikolaus Rath
Hello, All my Python files have extension .py. However, I would like to install scripts that are meant to be called by the user without the suffix, i.e. the file scripts/doit.py should end up as /usr/bin/doit. Apparently the scripts= option of the setup() function does not support this directly.

Re: python bijection

2009-12-04 Thread Lie Ryan
On 12/5/2009 9:41 AM, Carl Banks wrote: On Dec 4, 12:46 pm, geremy condra wrote: more common than full-blown graph package). Sure, its a tree, which is also a graph. In this case it looks to me more like a directed acyclic graph than anything, but its pretty much just semantics since the interf

Re: Redirecting stdin to a file

2009-12-04 Thread candide
@MRAB @Lie Ryan Thanks, it works fine ! -- http://mail.python.org/mailman/listinfo/python-list

Re: Redirecting stdin to a file

2009-12-04 Thread Lie Ryan
On 12/5/2009 10:31 AM, candide wrote: How do I redirect stdin to a text file ? In C, this can be done with the freopen() standard function, for instance FILE *foo = freopen("in.txt", "r", stdin); redirects stdin to the in.txt text file. Does anyone know a freopen() Python equivalent ? Notice

Re: How to timeout when waiting for raw_input from user ?

2009-12-04 Thread northof40
On Dec 5, 12:52 pm, northof40 wrote: > Hi - I'm writing a *very* simple program for my kids. It asks the user > to give it the answer to a maths question and says "right" or "wrong" > > They now want a timed version where they would only get so long to > respond to the question. > > I'm thinking o

Re: Question on class module import

2009-12-04 Thread Steven D'Aprano
On Fri, 04 Dec 2009 15:10:49 -0800, monkeyboy wrote: > Hello, > > I want to write a wrapper class around a windows dll. If I put the class > in a module "Refprop.py" then import the class where I want to use it, > does the whole module get read by the interpreter or just the class > code?... Eve

Re: Redirecting stdin to a file

2009-12-04 Thread MRAB
candide wrote: How do I redirect stdin to a text file ? In C, this can be done with the freopen() standard function, for instance FILE *foo = freopen("in.txt", "r", stdin); redirects stdin to the in.txt text file. Does anyone know a freopen() Python equivalent ? Notice that I'm not referring

How to timeout when waiting for raw_input from user ?

2009-12-04 Thread northof40
Hi - I'm writing a *very* simple program for my kids. It asks the user to give it the answer to a maths question and says "right" or "wrong" They now want a timed version where they would only get so long to respond to the question. I'm thinking of some logic where a raw_input call is executed an

Re: Question on class module import

2009-12-04 Thread MRAB
monkeyboy wrote: Hello, I want to write a wrapper class around a windows dll. If I put the class in a module "Refprop.py" then import the class where I want to use it, does the whole module get read by the interpreter or just the class code?... [snip] The whole module will be run. In Pytho

Re: subprocess kill

2009-12-04 Thread luca72
On 5 Dic, 00:14, luca72 wrote: > On 5 Dic, 00:03, luca72 wrote: > > > > > On 4 Dic, 23:23, Mike Driscoll wrote: > > > > On Dec 4, 3:50 pm, luca72 wrote: > > > > > Hello i'm using subprocess in this way: > > > > self.luca = subprocess.Popen(['/usr/bin/ > > > > dvbtune'+frase_sint],shell=True, st

Redirecting stdin to a file

2009-12-04 Thread candide
How do I redirect stdin to a text file ? In C, this can be done with the freopen() standard function, for instance FILE *foo = freopen("in.txt", "r", stdin); redirects stdin to the in.txt text file. Does anyone know a freopen() Python equivalent ? Notice that I'm not referring to shell redirect

Re: Difference between mutex.mutex and threading.Lock

2009-12-04 Thread Roy Smith
In article , zeph wrote: > The mutex class (and module) should not be used, since it is, as you > said, deprecated for 3.0. Like the docs say, it "does not require (or > imply) threading or multi-tasking, though it could be useful for those > purposes." Over the years, many things about Python

Re: subprocess kill

2009-12-04 Thread luca72
On 5 Dic, 00:03, luca72 wrote: > On 4 Dic, 23:23, Mike Driscoll wrote: > > > > > On Dec 4, 3:50 pm, luca72 wrote: > > > > Hello i'm using subprocess in this way: > > > self.luca = subprocess.Popen(['/usr/bin/ > > > dvbtune'+frase_sint],shell=True, stdout=self.f_s_l,stderr=self.f_s_e ) > > > > th

Question on class module import

2009-12-04 Thread monkeyboy
Hello, I want to write a wrapper class around a windows dll. If I put the class in a module "Refprop.py" then import the class where I want to use it, does the whole module get read by the interpreter or just the class code?... For example if I say the following in "Refprop.py" does the code abov

Re: subprocess kill

2009-12-04 Thread luca72
On 4 Dic, 23:23, Mike Driscoll wrote: > On Dec 4, 3:50 pm, luca72 wrote: > > > Hello i'm using subprocess in this way: > > self.luca = subprocess.Popen(['/usr/bin/ > > dvbtune'+frase_sint],shell=True, stdout=self.f_s_l,stderr=self.f_s_e ) > > > then i kill: > > self.luca.Kill() > > > but the proc

Re: Connecting to the users preferred email client

2009-12-04 Thread Tuomas Vesterinen
Mike Driscoll wrote: On Dec 4, 5:28 am, Tuomas Vesterinen wrote: If I want to open a html-page from Python code I can say: >>> import webbrowser >>> webbrowser.open('index.html') Is there a standard way to init an email in users preferred email client like Thubderbird, Evolution etc.? Tuom

Re: question about subprocess and shells

2009-12-04 Thread Lie Ryan
On 12/5/2009 8:38 AM, Ross Boylan wrote: If one uses subprocess.Popen(args, ..., shell=True, ...) When args finishes execution, does the shell terminate? Either way seems problematic. If it does not terminate, then it seems as if calls like wait and communicate would never return. It also see

Re: python bijection

2009-12-04 Thread Carl Banks
On Dec 4, 12:46 pm, geremy condra wrote: more common than full-blown graph package). > Sure, its a tree, which is also a graph. In this case it looks to > me more like a directed acyclic graph than anything, but its > pretty much just semantics since the interface is functionally > equivalent. I'

Re: subprocess kill

2009-12-04 Thread Mike Driscoll
On Dec 4, 3:50 pm, luca72 wrote: > Hello i'm using subprocess in this way: > self.luca = subprocess.Popen(['/usr/bin/ > dvbtune'+frase_sint],shell=True, stdout=self.f_s_l,stderr=self.f_s_e ) > > then i kill: > self.luca.Kill() > > but the process is still active and the file self.f_s_l increase it

Re: Difference between mutex.mutex and threading.Lock

2009-12-04 Thread zeph
The mutex class (and module) should not be used, since it is, as you said, deprecated for 3.0. Like the docs say, it "does not require (or imply) threading or multi-tasking, though it could be useful for those purposes." The mutex class' lock() method takes a function and args and if the mutex is

Re: Partial list comprehensions

2009-12-04 Thread Stephen Hansen
On Fri, Dec 4, 2009 at 2:11 PM, Joel Davis wrote: > Yes, sort of like that but Hansen's code is actually exactly what I > was getting at, not sure why he deleted it: Huh? I deleted it? --S -- http://mail.python.org/mailman/listinfo/python-list

Re: Partial list comprehensions

2009-12-04 Thread Joel Davis
On Dec 4, 3:41 pm, Mensanator wrote: > On Dec 4, 2:22 pm, Joel Davis wrote: > > > Is it possible to run a list comprehension over a certain portion of > > the list? My goals is to be able to run the comprehension on the > > innermost elements of the list, but leaving the outermost intact. > > Som

Re: Insane Problem

2009-12-04 Thread Lie Ryan
On 12/5/2009 8:27 AM, Terry Reedy wrote: Victor Subervi wrote: I'm not rude To me, asking for help without providing sufficient information, especially when requested, is a form of rudeness. Think about that and don't be rude. Why does this sounds familiar? http://groups.google.com/group/c

Specifying an API for a straeming parser

2009-12-04 Thread tyler
Howdy folks, I'm working on a JSON Python module [1] and I'm struggling with an appropriate syntax for dealing with incrementally parsing streams of data as they come in (off a socket or file object). The underlying C-level parsing library that I'm using (Yajl [2]) already uses a callback system

subprocess kill

2009-12-04 Thread luca72
Hello i'm using subprocess in this way: self.luca = subprocess.Popen(['/usr/bin/ dvbtune'+frase_sint],shell=True, stdout=self.f_s_l,stderr=self.f_s_e ) then i kill: self.luca.Kill() but the process is still active and the file self.f_s_l increase it size because the process is not killed. How i

question about subprocess and shells

2009-12-04 Thread Ross Boylan
If one uses subprocess.Popen(args, ..., shell=True, ...) When args finishes execution, does the shell terminate? Either way seems problematic. If it does not terminate, then it seems as if calls like wait and communicate would never return. It also seems the subprocess would never die, and that

Re: Killing Another Bug

2009-12-04 Thread Victor Subervi
On Fri, Dec 4, 2009 at 3:46 PM, Stephen Hansen wrote: > > On Fri, Dec 4, 2009 at 7:52 AM, Victor Subervi wrote: > >> except: >> > > >> except: >> pass >> > > If you want any hope of fixing the bug, remove both of these. Really -- do > not use bare excepts. > > In the first one, it lo

Re: python bijection

2009-12-04 Thread Terry Reedy
M.-A. Lemburg wrote: Integrating an easy-to-use graph library into the collections module (and it's C companion) is good idea. This would have to be written in C, though, That's currently in the works, along with database backing. We'd welcome any help though... hint, hint... The current th

Re: Insane Problem

2009-12-04 Thread Terry Reedy
Victor Subervi wrote: I'm not rude To me, asking for help without providing sufficient information, especially when requested, is a form of rudeness. Think about that and don't be rude. Exactly. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list

Re: Are routine objects guaranteed mutable & with dictionary?

2009-12-04 Thread Terry Reedy
Alf P. Steinbach wrote: > The question is what guarantees or absence thereof the language specification, PEPs, intentions, whatever gives/has. The two docs backed up by PEPs. I suppose the docs could be clearer. 5.3.1 says "The primary must evaluate to an object of a type that supports attrib

Re: How to tell if you're running on windows?

2009-12-04 Thread Roy Smith
In article , David Robinow wrote: > On Fri, Dec 4, 2009 at 1:46 PM, Roy Smith wrote: > > I'm using 2.5.1.  How can I tell if I'm running on windows?  The > > obvious answer, platform.system(), gets complicated.  On the python > > that comes with cygwin, it returns 'CYGWIN_NT-5.2-WOW64', but I'v

Re: Which is more pythonic?

2009-12-04 Thread nn
On Dec 3, 10:41 am, Filip Gruszczyński wrote: > I have just written a very small snippet of code and started thinking, > which version would be more pythonic. Basically, I am adding a list of > string to combo box in qt. So, the most obvious way is: > > for choice in self.__choices: >         choi

Re: Killing Another Bug

2009-12-04 Thread Stephen Hansen
On Fri, Dec 4, 2009 at 7:52 AM, Victor Subervi wrote: > except: > > except: > pass > If you want any hope of fixing the bug, remove both of these. Really -- do not use bare excepts. In the first one, it looks like you're expecting sometimes there to be an exception: that's okay.

Re: python bijection

2009-12-04 Thread geremy condra
On Fri, Dec 4, 2009 at 3:10 PM, Lie Ryan wrote: > On 12/5/2009 6:53 AM, geremy condra wrote: >> >> To be fair, I don't think you'd have to look very far to find places >> where a graph representation is approximated using some >> combination of dicts, sets, and lists. ElementTree comes to mind >>

Re: Partial list comprehensions

2009-12-04 Thread Mensanator
On Dec 4, 2:22 pm, Joel Davis wrote: > Is it possible to run a list comprehension over a certain portion of > the list? My goals is to be able to run the comprehension on the > innermost elements of the list, but leaving the outermost intact. Something like this? >>> a [0, 1, 2, 3, 4, 5, 6, 7, 8

Re: Partial list comprehensions

2009-12-04 Thread Stephen Hansen
> > Is it possible to run a list comprehension over a certain portion of > the list? My goals is to be able to run the comprehension on the > innermost elements of the list, but leaving the outermost intact. > Without seeing an example of what your list is, and what you want to turn it into, its s

Partial list comprehensions

2009-12-04 Thread Joel Davis
Is it possible to run a list comprehension over a certain portion of the list? My goals is to be able to run the comprehension on the innermost elements of the list, but leaving the outermost intact. -- http://mail.python.org/mailman/listinfo/python-list

Re: python bijection

2009-12-04 Thread Lie Ryan
On 12/5/2009 6:53 AM, geremy condra wrote: To be fair, I don't think you'd have to look very far to find places where a graph representation is approximated using some combination of dicts, sets, and lists. ElementTree comes to mind immediately, and the dict-of-dicts idea for logging recently dis

Re: Formatting logically nested actions -- Pythonic way?

2009-12-04 Thread Lie Ryan
On 12/4/2009 5:24 PM, Alf P. Steinbach wrote: Hi. I discovered with tkinter the registration of widgets with layout managers (tkinter "geometry" managers, e.g. calls to pack()) needs to be done very hierarchically. And this leads to hierarchical code, which would be nice to indicate by indentin

Re: How to tell if you're running on windows?

2009-12-04 Thread David Robinow
On Fri, Dec 4, 2009 at 1:46 PM, Roy Smith wrote: > I'm using 2.5.1.  How can I tell if I'm running on windows?  The > obvious answer, platform.system(), gets complicated.  On the python > that comes with cygwin, it returns 'CYGWIN_NT-5.2-WOW64', but I've got > a native windows build of python wher

Re: How to tell if you're running on windows?

2009-12-04 Thread Ross Ridge
Roy Smith wrote: >The real problem I'm trying to solve is whether to build a LIBPATH >environment variable with ';' or ':' delimiting the entries. On the >cygwin build, os.pathsep returns ':', which isn't really correct. If >you use that, you end up building paths that look like c:foo:c:bar. >I

Re: python bijection

2009-12-04 Thread geremy condra
On Fri, Dec 4, 2009 at 2:52 PM, geremy condra wrote: > On Fri, Dec 4, 2009 at 11:17 AM, MRAB wrote: >> M.-A. Lemburg wrote: >>> >>> geremy condra wrote: On Thu, Dec 3, 2009 at 12:57 PM, M.-A. Lemburg wrote: > > geremy condra wrote: >> >> On Thu, Dec 3, 2009 at 7:04 AM,

Re: Are routine objects guaranteed mutable & with dictionary?

2009-12-04 Thread Lie Ryan
On 12/5/2009 4:56 AM, Rami Chowdhury wrote: I don't think it was a problem of comprehension, more one of appropriate terminology -- AFAIK in Python, they're called functions, so calling them 'routines' is likely to confuse anyone in a discussion of Python features. Human language is not context

Re: More elegant solution for diffing two sequences

2009-12-04 Thread Lie Ryan
On 12/5/2009 4:20 AM, Ulrich Eckhardt wrote: Thinking about it, I perhaps should store the glyphs in a set from the beginning. Question is, can I (perhaps by providing the right hash function) sort them by their codepoint? I'll have to look at the docs... Python does not guarantee that a partic

Re: How to tell if you're running on windows?

2009-12-04 Thread Allan Davis
Try this import sys import os sep = None if sys.platform == 'cygwin': sep = ';' else: sep = os.pathsep # then use sep in your path statment Hope this helps Thanks, -- Allan Davis Member of NetBeans Dream Team http://wiki.netbeans.or

Re: How to tell if you're running on windows?

2009-12-04 Thread zeph
On Dec 4, 10:46 am, Roy Smith wrote: > I'm using 2.5.1. How can I tell if I'm running on windows? The > obvious answer, platform.system(), gets complicated. On the python > that comes with cygwin, it returns 'CYGWIN_NT-5.2-WOW64', but I've got > a native windows build of python where it returns

How to tell if you're running on windows?

2009-12-04 Thread Roy Smith
I'm using 2.5.1. How can I tell if I'm running on windows? The obvious answer, platform.system(), gets complicated. On the python that comes with cygwin, it returns 'CYGWIN_NT-5.2-WOW64', but I've got a native windows build of python where it returns 'Microsoft'. The real problem I'm trying to

Re: More elegant solution for diffing two sequences

2009-12-04 Thread MRAB
Ulrich Eckhardt wrote: Lie Ryan wrote: On 12/4/2009 8:28 AM, Ulrich Eckhardt wrote: I'm trying to write some code to diff two fonts. What I have is every character (glyph) of the two fonts in a list. I know that the list is sorted by the codepoints of the characters. What I'd like to ask is whe

Re: More elegant solution for diffing two sequences

2009-12-04 Thread Neil Cerutti
On 2009-12-04, Ulrich Eckhardt wrote: > Lie Ryan wrote: > Thinking about it, I perhaps should store the glyphs in a set > from the beginning. Question is, can I (perhaps by providing > the right hash function) sort them by their codepoint? I'll > have to look at the docs... No, sets are unordered

Re: Killing Another Bug

2009-12-04 Thread Victor Subervi
On Fri, Dec 4, 2009 at 2:08 PM, Victor Subervi wrote: > On Fri, Dec 4, 2009 at 12:43 PM, MRAB wrote: > >> Victor Subervi wrote: >> >>> Hi; >>> I have this code: >>> >>> >> [snip] >> >> As you can see in the supplied comments, when I loop through for table >>> 'prescriptions', it only prints out

Re: Killing Another Bug

2009-12-04 Thread Victor Subervi
On Fri, Dec 4, 2009 at 12:43 PM, MRAB wrote: > Victor Subervi wrote: > >> Hi; >> I have this code: >> >> > [snip] > > As you can see in the supplied comments, when I loop through for table >> 'prescriptions', it only prints out the first element of each variable. When >> I loop through for tabl

Re: memory error

2009-12-04 Thread Stephen Hansen
> > But-- the image does say Pythonwin... are you running this from the > Pythonwin editor/IDE? Does this script crash out if you run it through the > normal 'python'(or pythonw) commands? If not, are you attempting to do any > sort of GUI work in this script? That rarely works within Pythonwin > d

Re: Are routine objects guaranteed mutable & with dictionary?

2009-12-04 Thread Rami Chowdhury
>> BTW, it's a function, not a "routine" > > Wikipedia is your friend, http://en.wikipedia.org/wiki/Subroutine>. > > I don't think it was a problem of comprehension, more one of appropriate terminology -- AFAIK in Python, they're called functions, so calling them 'routines' is likely to confuse an

Re: More elegant solution for diffing two sequences

2009-12-04 Thread Ulrich Eckhardt
Lie Ryan wrote: > On 12/4/2009 8:28 AM, Ulrich Eckhardt wrote: >> I'm trying to write some code to diff two fonts. What I have is every >> character (glyph) of the two fonts in a list. I know that the list is >> sorted by the codepoints of the characters. What I'd like to ask is >> whether there is

Re: Killing Another Bug

2009-12-04 Thread MRAB
Victor Subervi wrote: Hi; I have this code: [snip] As you can see in the supplied comments, when I loop through for table 'prescriptions', it only prints out the first element of each variable. When I loop through for table 'products', it prints out all of them! Why? If you're serious a

Re: Why the expression "(1)" is not an one-arity tuple, but int ?

2009-12-04 Thread MRAB
Andre Engels wrote: 2009/12/4 Петров Александр : Hello All ! In my code I try to use a generic approach to work with tuples. Let "X" be a tuple. When I want to access a first element of a tuple, I can write: "X[0]". And that is really working when X is a n-arity tuple, with n>1 (for example "fo

Re: python bijection

2009-12-04 Thread MRAB
M.-A. Lemburg wrote: geremy condra wrote: On Thu, Dec 3, 2009 at 12:57 PM, M.-A. Lemburg wrote: geremy condra wrote: On Thu, Dec 3, 2009 at 7:04 AM, M.-A. Lemburg wrote: I think the only major CS data type missing from Python is some form of (fast) directed graph implementation à la kjGraph

Re: slightly OT: Python BootCamp

2009-12-04 Thread Neil Cerutti
On 2009-12-04, Steven D'Aprano wrote: > How would I re-write this? Just get rid of the try block and > add a close: > > for (exten, list) in files.iteritems(): > f=open('extensions-%s.txt' % exten,'w') > f.write('\n'.join(list)) "\n".join is a cute shortcut, but if you use it you must rem

Killing Another Bug

2009-12-04 Thread Victor Subervi
Hi; I have this code: for table in tables: if table == 'products': optionsCode = optionsCodeProducts fromForm = prodsFromForm try: fn = getattr(options, table) fromForm = form.getfirst('%s-options' % table) fromForm = string.split(fromForm[2:-2], "', '")

Re: Moving from Python 2 to Python 3: 4 page "cheat sheet" issue#3

2009-12-04 Thread Mark Summerfield
On 3 Dec, 01:17, Antoine Pitrou wrote: > Le Tue, 01 Dec 2009 06:03:36 -0800, Mark Summerfield a écrit : > > > I've produced a 4 page document that provides a very concise summary of > > Python 2<->3 differences plus the most commonly used new Python 3 > > features. It is aimed at existing Python 2

Re: Manyfile Processing

2009-12-04 Thread Peter Otten
u...@domain.invalid wrote: > On 12/04/2009 12:58 PM, Dan Sommers wrote: > > On Fri, 04 Dec 2009 10:00:53 +0200, user wrote: > > > >> sorry if i bother you with a beginners question but i have an issue > >> with processing a bunch of files. They are some arithmetic lists the > >> processing of on

Re: testing command line scripts that use optparse

2009-12-04 Thread Jean-Michel Pichavant
Peter wrote: Hi I have a script like this: def doit(input, output): parser = OptionParser() parser.add_option("-a", "--accounts", dest="accounts", default="all", help="list available accounts") ... (options, args) = parser.parse_args() # main driver if __name__ == "__mai

Re: Feature request: String-inferred names

2009-12-04 Thread Bruno Desthuilliers
Brad Harms a écrit : On Fri, 04 Dec 2009 18:05:03 +1100, Ben Finney wrote: (snip) 2.) Attributes whose values are determined or assigned dynamically by indirectly calling a function (like properties and instancemethods) Yes, the term “property” seems to do what you want. I wasn't asking what

Re: Feature request: String-inferred names

2009-12-04 Thread Bruno Desthuilliers
Ben Finney a écrit : Brad Harms writes: (snip) 2.) Attributes whose values are determined or assigned dynamically by indirectly calling a function (like properties and instancemethods) Yes, the term “property” seems to do what you want. The property type is just one possible application o

Re: Feature request: String-inferred names

2009-12-04 Thread Bruno Desthuilliers
Brad Harms a écrit : On Tue, 2009-12-01 at 16:58 +0100, Bruno Desthuilliers wrote: The Music Guy a écrit : (snip) Lie Ryan, I think I see what you're saying about using __dict__ to add members No "members" in Python - only attributes. to a class, but it's not quite the same. __dict__ is onl

Difference between mutex.mutex and threading.Lock

2009-12-04 Thread sven
Hi, what is the difference between mutex.mutex and threading.Lock? Neither the documentation nor a Google search gave me any clue. Another issue: The documentation of mutex in version 2.6.4 says: "Deprecated since version The: mutex module has been removed in Python 3.0." Maybe it should also s

Re: Question on Python as career

2009-12-04 Thread joy99
On Dec 4, 6:53 pm, Michele Simionato wrote: > After 5 years of postdoc in Physics I decided to changecareerand to > move to IT. I decided to learn Object Oriented Programming first. I > chosePythonsince it was already installed on my Linux machine and it > was easy to tackle for a beginner. In the

Re: Manyfile Processing

2009-12-04 Thread user
On 12/04/2009 12:58 PM, Dan Sommers wrote: > On Fri, 04 Dec 2009 10:00:53 +0200, user wrote: > >> sorry if i bother you with a beginners question but i have an issue >> with processing a bunch of files. They are some arithmetic lists the >> processing of one file is an easy task but how do i proc

Re: editor with autocompletion

2009-12-04 Thread Gerhard Häring
Siva B wrote: > Hi friends, > > I am writing a new language. > So I want an editor with auto complete. > I there any such tool in Python ?(not only in python any other) > I want it for my new lang IDLE, the Integrated Development Environment included with your Python installation nowadays has aut

RE: memory error

2009-12-04 Thread Ahmed, Shakir
From: python-list-bounces+shahmed=sfwmd@python.org [mailto:python-list-bounces+shahmed=sfwmd@python.org] On Behalf Of Stephen Hansen Sent: Thursday, December 03, 2009 10:22 PM To: python-list@python.org Subject: Re: memory error On Thu, Dec 3, 2009 at 5:51 AM, Ahmed, Shakir wro

Re: Connecting to the users preferred email client

2009-12-04 Thread Mike Driscoll
On Dec 4, 5:28 am, Tuomas Vesterinen wrote: > If I want to open a html-page from Python code I can say: > >  >>> import webbrowser >  >>> webbrowser.open('index.html') > > Is there a standard way to init an email in users preferred email client > like Thubderbird, Evolution etc.? > > Tuomas Vester

Re: Question on Python as career

2009-12-04 Thread Michele Simionato
After 5 years of postdoc in Physics I decided to change career and to move to IT. I decided to learn Object Oriented Programming first. I chose Python since it was already installed on my Linux machine and it was easy to tackle for a beginner. In the process of learning Python I began posting to th

Re: editor with autocompletion

2009-12-04 Thread mynthon
On 4 Gru, 13:37, Tim Chase wrote: > > So I want an editor with auto complete. > > I there any such tool in Python ?(not only in python any other) > > I want it for my new lang > > vim?  emacs?  or do you want the editor to be written in Python? > > -tkc Try ActiveState Komodo (or free version: Ko

Re: Manyfile Processing

2009-12-04 Thread km
use glob module Krishna On Fri, Dec 4, 2009 at 6:37 PM, Diez B. Roggisch wrote: > u...@domain.invalid schrieb: > >> Hey, >> >> sorry if i bother you with a beginners question but i have an issue >> with processing a bunch of files. They are some arithmetic lists the >> processing of one file is

Re: Feature request: String-inferred names

2009-12-04 Thread Steven D'Aprano
On Thu, 03 Dec 2009 23:12:39 -0600, Brad Harms wrote: > On Tue, 2009-12-01 at 14:38 +, Steven D'Aprano wrote: [...] >> It's just special double-underscore methods like __init__ __add__ etc >> that have to be in the class rather than the instance. (To be precise, >> you can add such a method to

Re: editor with autocompletion

2009-12-04 Thread Tim Chase
So I want an editor with auto complete. I there any such tool in Python ?(not only in python any other) I want it for my new lang vim? emacs? or do you want the editor to be written in Python? -tkc -- http://mail.python.org/mailman/listinfo/python-list

logging module, SMTPHandler and gmail in python 2.6

2009-12-04 Thread mynthon
You cannot use gmail account for sending emails with logging module. It is because google requires TLS connection and logging module doesn't support it. To use gmail you have to extend logging.handlers.SMTPHandler class and override SMTPHandler.emit() method. Here is source code. (There really sho

  1   2   >