Re: adding a directory to sys.path

2009-11-23 Thread Paul Miller
On Mon, 23 Nov 2009 12:02:36 -0500, John Guenther wrote: > This is Mac related. I am running snow leopard. I am using Python 2.6.3. > > I had a lot of difficulty figuring out how to add a directory to > sys.path that would be there every time I launched Idle. [...] For a comprehensive discussion

Re: midi file parser

2009-11-23 Thread alex23
On Nov 24, 3:15 pm, Sean McIlroy wrote: > [code snipped] Great stuff. Have you considered bundling it up and putting it onto PyPI? -- http://mail.python.org/mailman/listinfo/python-list

Re: Where to put the error handing test?

2009-11-23 Thread alex23
On Nov 24, 1:15 pm, Peng Yu wrote: > Suppose that I have function f() that calls g(), I can put a test on > the argument 'x' in either g() or f(). I'm wondering what is the > common practice. > > If I put the test in f(), then g() becomes more efficient when other > code call g() and guarantee x w

Re: Any elegant way to construct the complete $k$-partite graph in Python?

2009-11-23 Thread Paul Miller
On Mon, 23 Nov 2009 19:57:05 -0800, Richard Thomas wrote: > Not sure exactly how you're representing graphs, this seems like the > simplest way of listing the edges. > > def complete_partite(*sizes): > total = sum(sizes) > nodes, edges = range(total), [] > for group in xrange(len(size

Re: sys.stdout is not flushed

2009-11-23 Thread Nobody
On Mon, 23 Nov 2009 23:08:25 +0100, Diez B. Roggisch wrote: > Try printing > >stdout.write('\r-->%d') ^M-->0^M-->1^M-->2^M-->3... ;) But it's probably good enough for the OP's purposes. -- http://mail.python.org/mailman/listinfo/python-list

Re: UnicodeDecodeError? Argh! Nothing works! I'm tired and hurting and...

2009-11-23 Thread Nobody
On Mon, 23 Nov 2009 22:06:29 +0100, Alf P. Steinbach wrote: > 10. It says UnicodeDecodeError on mail nr. something something. That's what you get for using Python 3.x ;) If you must use 3.x, don't use the standard descriptors. If you must use the standard descriptors in 3.x, call detach() on the

Re: Relative versus absolute paths on Windows

2009-11-23 Thread Nobody
On Tue, 24 Nov 2009 02:23:19 +0100, Christian Heimes wrote: > Gregory Ewing wrote: >> ntpath.join('d:\\foo', '\\bar') >>> '\\bar' >> >> This does seem like a bug, though -- the correct result >> should really be 'd:\\bar', since that's what you would >> get if you used the name '\\bar' with '

Re: Line Breaks

2009-11-23 Thread Gary Herron
Susan Day wrote: On Mon, Nov 23, 2009 at 2:26 PM, Gary Herron mailto:gher...@islandtraining.com>> wrote: >>> print 'A Message From %s:\n\n %s' % ('someone','some message') A Message From someone: some message So... *Exactly* what are you doing with msg, and *exactly* what

midi file parser

2009-11-23 Thread Sean McIlroy
""" A Sequence is a list [FormatType, TimeDivision, Tracks] where *) FormatType is in [0,1,2] *) TimeDivision is either [TicksPerBeat] with TicksPerBeat in range (2**15) or [FramesPerSecond, TicksPerFrame] with FramesPerSecond in range (2**7) and TicksPerFrame in range(2**8) *) Tracks is a

Re: sys.stdout is not flushed

2009-11-23 Thread Jankins
On Nov 23, 8:54 pm, Dave Angel wrote: > Jankins wrote: > > On Nov 23, 4:08 pm, "Diez B. Roggisch" wrote: > > >> Jankins schrieb: > > >>> I am trying to use sys.stdout to print out "process-bar" like: > >>> -->1% > > >>> Here is my program ‘test.py’: > > >>> from sys import stdout > >>> for v in r

Re: sys.stdout is not flushed

2009-11-23 Thread Jankins
On Nov 23, 8:32 pm, Cousin Stanley wrote: > >> > >> You misunderstand what "flush" means. It is not about > >> clearing the screen, or the line. > > >> Try printing > > >>    stdout.write('\r-->%d') > > >> Diez > > > But there is still a problem. When you use control character '\r', > > you a

Re: Where to put the error handing test?

2009-11-23 Thread Peng Yu
On Mon, Nov 23, 2009 at 9:44 PM, Lie Ryan wrote: > Peng Yu wrote: >> >> Suppose that I have function f() that calls g(), I can put a test on >> the argument 'x' in either g() or f(). I'm wondering what is the >> common practice. >> >> My thought is that if I put the test in g(x), the code of g(x)

Re: UnicodeDecodeError? Argh! Nothing works! I'm tired and hurting and...

2009-11-23 Thread Lie Ryan
Alf P. Steinbach wrote: And I'm hesitant to just delete index file, hoping that it'll rebuild. it'll be rebuild the next time you start Thunderbird: (MozillaZine: http://kb.mozillazine.org/Disappearing_mail) * It's possible that the ".msf" files (index files) are corrupted. To rebuild the in

Re: Line Breaks

2009-11-23 Thread Lie Ryan
D'Arcy J.M. Cain wrote: On Mon, 23 Nov 2009 14:46:23 -0500 Susan Day wrote: First, it does in fact ignore all line breaks, not just double line breaks. Here's what I'm doing: session.sendmail(clientEmail, ourEmail2, header+msg) The email sent out has the message sans breaks. You should really

Re: More precise document on os.path.normpath()

2009-11-23 Thread Lie Ryan
Peng Yu wrote: After I tried os.path.normpath(), it is clear that the function doesn't return the trailing '/', if the path is a directory. But this fact is not documented. Should this be documented in future release of python. Also, I found the documentation of some functions in os.path are not

Re: Any elegant way to construct the complete $k$-partite graph in Python?

2009-11-23 Thread Richard Thomas
On Nov 24, 2:45 am, geremy condra wrote: > On Mon, Nov 23, 2009 at 9:10 PM, geremy condra wrote: > > On Mon, Nov 23, 2009 at 9:03 PM, geremy condra wrote: > >> On Mon, Nov 23, 2009 at 7:05 PM, Paul Miller > >> wrote: > >>> I was wondering if there were any neat tools (like for instance, > >>> s

Re: Where to put the error handing test?

2009-11-23 Thread Lie Ryan
Peng Yu wrote: Suppose that I have function f() that calls g(), I can put a test on the argument 'x' in either g() or f(). I'm wondering what is the common practice. My thought is that if I put the test in g(x), the code of g(x) is safer, but the test is not necessary when g() is called by h().

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread r
On Nov 23, 11:19 am, astral orange <457r0...@gmail.com> wrote: > Hi, I am trying to teach myself Python and have a good book to help me > but I am stuck on something and I would like for someone to explain > the following piece of code for me and what it's actually doing. > Certain parts are very c

Where to put the error handing test?

2009-11-23 Thread Peng Yu
Suppose that I have function f() that calls g(), I can put a test on the argument 'x' in either g() or f(). I'm wondering what is the common practice. My thought is that if I put the test in g(x), the code of g(x) is safer, but the test is not necessary when g() is called by h(). If I put the tes

Re: [repost please help me] python setup.py build for 32-bits on x86_64 machine

2009-11-23 Thread Sérgio Monteiro Basto
Diez B. Roggisch wrote: > Sérgio Monteiro Basto schrieb: >> Diez B. Roggisch wrote: >> >> Hi, Thanks, >>> Sérgio Monteiro Basto wrote: >>> Hi, I am in x86_64 arch , but I need compile things on 32 bits with python setup.py build Can't change the fact that distutils cr

Re: sys.stdout is not flushed

2009-11-23 Thread Dave Angel
Jankins wrote: On Nov 23, 4:08 pm, "Diez B. Roggisch" wrote: Jankins schrieb: I am trying to use sys.stdout to print out "process-bar" like: -->1% Here is my program ‘test.py’: from sys import stdout for v in range(10): stdout.write('-->%d' % v) stdout.flu

Re: More precise document on os.path.normpath()

2009-11-23 Thread Carl Banks
On Nov 23, 5:59 pm, Benjamin Kaplan wrote: > On Mon, Nov 23, 2009 at 8:52 PM, Peng Yu wrote: > > After I tried os.path.normpath(), it is clear that the function > > doesn't return the trailing '/', if the path is a directory. But this > > fact is not documented. Should this be documented in futur

Re: Any elegant way to construct the complete $k$-partite graph in Python?

2009-11-23 Thread geremy condra
On Mon, Nov 23, 2009 at 9:10 PM, geremy condra wrote: > On Mon, Nov 23, 2009 at 9:03 PM, geremy condra wrote: >> On Mon, Nov 23, 2009 at 7:05 PM, Paul Miller >> wrote: >>> I was wondering if there were any neat tools (like for instance, >>> something from itertools) that would help me write the

Re: sys.stdout is not flushed

2009-11-23 Thread Cousin Stanley
>> >> You misunderstand what "flush" means. It is not about >> clearing the screen, or the line. >> >> Try printing >> >>    stdout.write('\r-->%d') >> >> Diez > > > But there is still a problem. When you use control character '\r', > you actually move to the head of the current buffer line

Re: Waiting for receiving data

2009-11-23 Thread Gerald Walker
> > import socket > from urllib2 import urlopen > > # A one-hundredths of a second (0.01) timeout before socket throws > # an exception to demonstrate catching the timeout. > # Obviously, this you will set this greater than 0.01 in real life. > socket.setdefaulttimeout(0.01) > > # example xml f

Re: [CPyUG:110052] ANN: UliPad 4.0 released!

2009-11-23 Thread Gang(Gary) Wu
很不错!虽然我一直用emacs On Tue, Nov 24, 2009 at 10:16 AM, limodou wrote: > UliPad is a flexible editor, based on wxPython. It's has many > features,just like:class browser, code auto-complete, html viewer, directory > browser, wizard, etc. The main feature is the usage of mixin. This makes > UliPad can

ANN: UliPad 4.0 released!

2009-11-23 Thread limodou
UliPad is a flexible editor, based on wxPython. It's has many features,just like:class browser, code auto-complete, html viewer, directory browser, wizard, etc. The main feature is the usage of mixin. This makes UliPad can be extended easily. So you can write your own mixin or plugin, or simple sc

Re: sys.stdout is not flushed

2009-11-23 Thread Jankins
On Nov 23, 4:08 pm, "Diez B. Roggisch" wrote: > Jankins schrieb: > > > > > > > I am trying to use sys.stdout to print out "process-bar" like: > > -->1% > > > Here is my program ‘test.py’: > > > from sys import stdout > > for v in range(10): > >     stdout.write('-->%d' % v) > >     stdout.flush()

Re: Capturing output of os.system to a string

2009-11-23 Thread gerry.butler
Thank you. I'll look at subprocess. I have since found that commands will do it too, eg, (status, txt) = commands.getstatusoutput('whoami') or txt = commands.getoutput('whoami') -- http://mail.python.org/mailman/listinfo/python-list

Re: Any elegant way to construct the complete $k$-partite graph in Python?

2009-11-23 Thread geremy condra
On Mon, Nov 23, 2009 at 9:03 PM, geremy condra wrote: > On Mon, Nov 23, 2009 at 7:05 PM, Paul Miller > wrote: >> I was wondering if there were any neat tools (like for instance, >> something from itertools) that would help me write the following function >> more elegantly.  The return value shoul

Re: profiling differences using an extra function call

2009-11-23 Thread Lie Ryan
marc magrans de abril wrote: Hi, I was a trying to profile a small script and after shrinking the code to the minimum I got a interesting profile difference. Given two test functions test1 and test2, that only differs from an extra level of indirection (i.e. find_substr), That's because there

Re: Waiting for receiving data

2009-11-23 Thread Gerald Walker
> > Also, if you are using multiple threads to retrieve the xml source(s) > and any thread blocks due to network problems, the thread can go way by > itself after the default timeout expires. > > Typo, edited for clarity: That is: "..the thread can go *away* by itself after the default timeout

Re: Waiting for receiving data

2009-11-23 Thread Gerald Walker
> > import socket > from urllib2 import urlopen > > # A one-hundredths of a second (0.01) timeout before socket throws > # an exception to demonstrate catching the timeout. > # Obviously, this you will set this greater than 0.01 in real life. > socket.setdefaulttimeout(0.01) > > # example xml f

Re: Any elegant way to construct the complete $k$-partite graph in Python?

2009-11-23 Thread geremy condra
On Mon, Nov 23, 2009 at 7:05 PM, Paul Miller wrote: > I was wondering if there were any neat tools (like for instance, > something from itertools) that would help me write the following function > more elegantly.  The return value should, of course, be the complete $k$- > partite graph $K_{n_1, n_

Re: More precise document on os.path.normpath()

2009-11-23 Thread Benjamin Kaplan
On Mon, Nov 23, 2009 at 8:52 PM, Peng Yu wrote: > After I tried os.path.normpath(), it is clear that the function > doesn't return the trailing '/', if the path is a directory. But this > fact is not documented. Should this be documented in future release of > python. > > Also, I found the documen

Re: Waiting for receiving data

2009-11-23 Thread Gerald Walker
Anjanesh Lekshminarayanan wrote: > fp = urllib.urlopen(url) > data = fp.read() > > Retrieving XML data via an XML service API. > Very often network gets stuck in between. No errors / exceptions. > > CTRL+C > > File "get-xml.py", line 32, in > fp = urllib.urlopen(url) > File "/usr/lib/py

More precise document on os.path.normpath()

2009-11-23 Thread Peng Yu
After I tried os.path.normpath(), it is clear that the function doesn't return the trailing '/', if the path is a directory. But this fact is not documented. Should this be documented in future release of python. Also, I found the documentation of some functions in os.path are not clear. I have to

Re: Relative versus absolute paths on Windows

2009-11-23 Thread Ethan Furman
Christian Heimes wrote: Gregory Ewing wrote: ntpath.join('d:\\foo', '\\bar') '\\bar' This does seem like a bug, though -- the correct result should really be 'd:\\bar', since that's what you would get if you used the name '\\bar' with 'd:' as your current drive. No, it's not a bug. Since

Re: UnicodeDecodeError? Argh! Nothing works! I'm tired and hurting and...

2009-11-23 Thread Terry Reedy
Alf P. Steinbach wrote: import os import fileinput def write( s ): print( s, end = "" ) I believe this is the same as write = sys.stdout.write though you never use it that I see. msg_id = 0 f = open( "nul", "w" ) for line in fileinput.input( mode = "rb" ): I presume you are expecting the

Re: Capturing output of os.system to a string

2009-11-23 Thread Lie Ryan
gerry.butler wrote: How do I capture output to a string? For example, the output of os.system('whoami'). I guess I need to redirect stdout, but I'm a total beginner, and I haven't been able to find out from the tutorials how to do this. You can't with os.system; use subprocess module instead.

Re: Capturing output of os.system to a string

2009-11-23 Thread Stephen Hansen
On Mon, Nov 23, 2009 at 5:27 PM, gerry.butler wrote: > How do I capture output to a string? For example, the output of > os.system('whoami'). > > I guess I need to redirect stdout, but I'm a total beginner, and I > haven't been able to find out from the tutorials how to do this. > > You don't; os.

Capturing output of os.system to a string

2009-11-23 Thread gerry.butler
How do I capture output to a string? For example, the output of os.system('whoami'). I guess I need to redirect stdout, but I'm a total beginner, and I haven't been able to find out from the tutorials how to do this. -- http://mail.python.org/mailman/listinfo/python-list

Re: Relative versus absolute paths on Windows

2009-11-23 Thread Christian Heimes
Gregory Ewing wrote: > ntpath.join('d:\\foo', '\\bar') >> '\\bar' > > This does seem like a bug, though -- the correct result > should really be 'd:\\bar', since that's what you would > get if you used the name '\\bar' with 'd:' as your current > drive. No, it's not a bug. Since \bar is an ab

Re: Line-continuation "Anti-Idiom" and with statement

2009-11-23 Thread Terry Reedy
MRAB wrote: Neil Cerutti wrote: > I installed Python 3.1 today, and I've been porting my small > library of programs to the new system. > > I happened to read the interesting "Idioms and Anti-Idioms" > HOWTO, and saw the '\' continuation character labeled an > anti-idiom. I already generall

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread Terry Reedy
astral orange wrote: As far as the program. I did add print statements such as print (MyNames) and got back: {'middle': {}, 'last': {'Smith': ['John Larry Smith']}, 'first': {}} Hmmm, as I understood the code, either that should be ... 'last': {} ... before the first store(), as you seem to b

Re: Python & OpenOffice Spreadsheets

2009-11-23 Thread r
On Nov 23, 4:49 am, Gerhard Häring wrote: > Is there a *simple* way to read OpenOffice spreadsheets? > > Bonus: write them, too? > > I mean something like: > > doc.cells[0][0] = "foo" > doc.save("xyz.ods") > > >From a quick look, pyodf offers little more than just using a XML parser I find the s

Re: Any elegant way to construct the complete $k$-partite graph in Python?

2009-11-23 Thread anand jeyahar
I am not sure what you mean by complete $k$- partite graph There is the python-graph package(http://code.google.com/p/python-graph/) you might wanna check out. It does return a complete graph.. may be u can tweak it?? == Anand J http://sites.google.co

Any elegant way to construct the complete $k$-partite graph in Python?

2009-11-23 Thread Paul Miller
I was wondering if there were any neat tools (like for instance, something from itertools) that would help me write the following function more elegantly. The return value should, of course, be the complete $k$- partite graph $K_{n_1, n_2, \dots, n_k}$: def completeGraph (*ns): ''' Retu

Re: Go versus Brand X

2009-11-23 Thread Gregory Ewing
Robert Kern wrote: The easier it is to write *a* parser/analyzer for the language in any other programming language, the more tools you will get for a broader range of runtime environments, particularly constrained environments like editors that may not be extensible at all. Seems to me that

Re: Line-continuation "Anti-Idiom" and with statement

2009-11-23 Thread Terry Reedy
Neil Cerutti wrote: I installed Python 3.1 today, and I've been porting my small library of programs to the new system. I happened to read the interesting "Idioms and Anti-Idioms" HOWTO, and saw the '\' continuation character labeled an anti-idiom. I already generally avoided it, so I just nodde

Re: Relative versus absolute paths on Windows

2009-11-23 Thread Ethan Furman
Jason R. Coombs wrote: On Nov 20, 3:52 pm, Ethan Furman wrote: It is often said on this list that 'Python is not Java'. It is also true that 'Windows is not Unix'. Unlike the *nix world where there is a *single* root, and everything else is relative to that, in the Windows world there are se

Re: IDE+hg

2009-11-23 Thread Rhodri James
On Mon, 23 Nov 2009 19:20:27 -, NiklasRTZ wrote: Dear experts, Since no py IDE I found has easy hg access. IDEs PIDA and Eric claim Mercurial support not found i.e. buttons to clone, commit and push to repositories to define dev env dvcs, editor and deployment all in 1. I don't really und

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread astral orange
On Nov 23, 4:35 pm, Terry Reedy wrote: > astral orange wrote: > > Yes, lines 104-111 is really where my problem lies in understanding > > what is going on here. > > I am beginner so this stuff seems a little unwieldy at the moment. :) > > I *did* invest $40 > > Water under the bridge. Focus on the

Re: sys.stdout is not flushed

2009-11-23 Thread Jankins
On Nov 23, 4:08 pm, "Diez B. Roggisch" wrote: > Jankins schrieb: > > > > > > > I am trying to use sys.stdout to print out "process-bar" like: > > -->1% > > > Here is my program ‘test.py’: > > > from sys import stdout > > for v in range(10): > >     stdout.write('-->%d' % v) > >     stdout.flush()

Re: UnicodeDecodeError? Argh! Nothing works! I'm tired and hurting and...

2009-11-23 Thread Alf P. Steinbach
* Alf P. Steinbach: import os import fileinput def write( s ): print( s, end = "" ) msg_id = 0 f = open( "nul", "w" ) for line in fileinput.input( mode = "rb" ): if line.startswith( "From - " ): msg_id += 1; f.close() print( msg_id ) f = open( "msg_{0:0>6}.

Re: sys.stdout is not flushed

2009-11-23 Thread Diez B. Roggisch
Jankins schrieb: I am trying to use sys.stdout to print out "process-bar" like: -->1% Here is my program ‘test.py’: from sys import stdout for v in range(10): stdout.write('-->%d' % v) stdout.flush() else: stdout.write('done!') #end for Then, I use 'python -u test.py' to run this s

Re: xmlrpc idea for getting around the GIL

2009-11-23 Thread Martin v. Löwis
> What I meant was that I am *not allowed* to make calls to the CPython > API from the threads I currently have because these threads are high > priority and are never allowed to make blocking calls. Fortunately, > each of these threads can have a completely separate interpreter, so > my idea was t

Re: [repost please help me] python setup.py build for 32-bits on x86_64 machine

2009-11-23 Thread Diez B. Roggisch
Sérgio Monteiro Basto schrieb: Diez B. Roggisch wrote: Hi, Thanks, Sérgio Monteiro Basto wrote: Hi, I am in x86_64 arch , but I need compile things on 32 bits with python setup.py build Can't change the fact that distutils creates x86_64 directories: build/temp.linux-x86_64-2.3/ Also if I t

Re: Relative versus absolute paths on Windows

2009-11-23 Thread Jason R. Coombs
On Nov 20, 3:52 pm, Ethan Furman wrote: > It is often said on this list that 'Python is not Java'.  It is also > true that 'Windows is not Unix'. > > Unlike the *nix world where there is a *single* root, and everything > else is relative to that, in the Windows world there are several roots > -- e

sys.stdout is not flushed

2009-11-23 Thread Jankins
I am trying to use sys.stdout to print out "process-bar" like: -->1% Here is my program ‘test.py’: from sys import stdout for v in range(10): stdout.write('-->%d' % v) stdout.flush() else: stdout.write('done!') #end for Then, I use 'python -u test.py' to run this script. But what I g

Compiling Python 2.6.4 on IRIX 6.5 - "don't know how to make Parser/printgrammar.o (bu42)."

2009-11-23 Thread James Looney
I'm trying to compile Python 2.6.4 on my IRIX 6.5 machine. I have no idea how to fix this problem, and am hoping someone may know what to do. The closest thread I've found to this is http://bugs.python.org/issue4279, but that patch has already been added, yet I still get the error. The post make

Compiling Python 2.6.4 on IRIX 6.5 - "don't know how to make Parser/printgrammar.o (bu42)."

2009-11-23 Thread James Looney
I'm trying to compile Python 2.6.4 on my IRIX 6.5 machine. I have no idea how to fix this problem, and am hoping someone may know what to do. The closest thread I've found to this is http://bugs.python.org/issue4279, but that patch has already been added, yet I still get the error. The post make

profiling differences using an extra function call

2009-11-23 Thread marc magrans de abril
Hi, I was a trying to profile a small script and after shrinking the code to the minimum I got a interesting profile difference. Given two test functions test1 and test2, that only differs from an extra level of indirection (i.e. find_substr), I wonder why I got a timming difference >50%? What is

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread Terry Reedy
astral orange wrote: Yes, lines 104-111 is really where my problem lies in understanding what is going on here. I am beginner so this stuff seems a little unwieldy at the moment. :) I *did* invest $40 Water under the bridge. Focus on the future... into this book so it' what I have to work wi

Re: Line Breaks

2009-11-23 Thread D'Arcy J.M. Cain
On Mon, 23 Nov 2009 14:46:23 -0500 Susan Day wrote: > First, it does in fact ignore all line breaks, not just double line breaks. > Here's what I'm doing: > session.sendmail(clientEmail, ourEmail2, header+msg) > The email sent out has the message sans breaks. You should really post an entire scri

Re: Go versus Brand X

2009-11-23 Thread Robert Kern
On 2009-11-23 14:47 PM, Antoine Pitrou wrote: Le Mon, 23 Nov 2009 11:54:19 -0600, Robert Kern a écrit : Not really. The idea was to make the language easily parsed and lexed and analyzed by *other* tools, not written in Go, that may have limited capabilities. Well, if Go doesn't allow you to

Re: Converting a float to a formatted outside of print command

2009-11-23 Thread Vlastimil Brom
2009/11/23 stephen_b : > I'd like to convert a list of floats to formatted strings. The > following example raises a TypeError: > > y = 0.5 > x = '.1f' % y > -- > http://mail.python.org/mailman/listinfo/python-list Maybe '%.1f' % y ? hth vbr -- http://mail.python.org/mailman/listinfo/python-lis

Re: Converting a float to a formatted outside of print command

2009-11-23 Thread Philip Semanchuk
On Nov 23, 2009, at 4:15 PM, stephen_b wrote: I'd like to convert a list of floats to formatted strings. The following example raises a TypeError: y = 0.5 x = '.1f' % y You're missing a percent sign: x = '%.1f' % y or: print '%.1f' % 0.5 Hope this helps Philip -- http://mail.python.o

Re: Converting a float to a formatted outside of print command

2009-11-23 Thread Iuri
You forgot a % simbol in your string: y = 0.5 x = '*%*.1f' % y []s iurisilvio On Mon, Nov 23, 2009 at 7:15 PM, stephen_b wrote: > I'd like to convert a list of floats to formatted strings. The > following example raises a TypeError: > > y = 0.5 > x = '.1f' % y > -- > http://mail.python.org/mai

Re: Converting a float to a formatted outside of print command

2009-11-23 Thread Dan Bishop
On Nov 23, 3:15 pm, stephen_b wrote: > I'd like to convert a list of floats to formatted strings. The > following example raises a TypeError: > > y = 0.5 > x = '.1f' % y You meant: x = '%.1f' % y -- http://mail.python.org/mailman/listinfo/python-list

Converting a float to a formatted outside of print command

2009-11-23 Thread stephen_b
I'd like to convert a list of floats to formatted strings. The following example raises a TypeError: y = 0.5 x = '.1f' % y -- http://mail.python.org/mailman/listinfo/python-list

Re: xmlrpc idea for getting around the GIL

2009-11-23 Thread Diez B. Roggisch
Patrick Stinson schrieb: On Mon, Nov 23, 2009 at 1:01 AM, Carl Banks wrote: On Nov 22, 10:58 pm, Patrick Stinson wrote: On Sun, Nov 22, 2009 at 3:15 PM, Diez B. Roggisch wrote: icating) the multiprocessing module would be ideal. The problem is that the OP has a embedded application running

UnicodeDecodeError? Argh! Nothing works! I'm tired and hurting and...

2009-11-23 Thread Alf P. Steinbach
This is the tragic story of this evening: 1. Aspirins to lessen the pain somewhat. 2. Over in [comp.programming] someone mentions paper on Quicksort. 3. I recall that X once sent me link to paper about how to foil Quicksort, written by was it Doug McIlroy, anyway some Bell Labs guy. Want to

Re: xmlrpc idea for getting around the GIL

2009-11-23 Thread Patrick Stinson
On Mon, Nov 23, 2009 at 1:01 AM, Carl Banks wrote: > On Nov 22, 10:58 pm, Patrick Stinson > wrote: >> On Sun, Nov 22, 2009 at 3:15 PM, Diez B. Roggisch >> wrote: > icating) the multiprocessing module would be ideal. >> > The problem is that the OP has a embedded application running threads. >>

Re: A More Concise Description of Numpy than the Guide to Numpy?

2009-11-23 Thread W. eWatson
Robert Kern wrote: On 2009-11-23 11:49 AM, W. eWatson wrote: I'm looking the 300+ page pdf of the Guide to Numpy. Is there a more concise and practical guide to its use in science and mathematics? You will want to ask numpy questions on the numpy mailing list: http://www.scipy.org/Mailing_L

Re: IDE+hg

2009-11-23 Thread Joshua Kugler
NiklasRTZ wrote: > If you > know > a good light IDE with hg, please inform. Topic handled earlier, still > undecided > http://groups.google.com/group/google-appengine-python/browse_thread/... > Thanks in advance > Niklas Rosencrantz WingIDE support Hg, as well as svn, git, and many others. j --

Waiting for receiving data

2009-11-23 Thread Anjanesh Lekshminarayanan
fp = urllib.urlopen(url) data = fp.read() Retrieving XML data via an XML service API. Very often network gets stuck in between. No errors / exceptions. CTRL+C File "get-xml.py", line 32, in fp = urllib.urlopen(url) File "/usr/lib/python2.6/urllib.py", line 87, in urlopen return open

Re: Go versus Brand X

2009-11-23 Thread Antoine Pitrou
Le Mon, 23 Nov 2009 11:54:19 -0600, Robert Kern a écrit : > > Not really. The idea was to make the language easily parsed and lexed > and analyzed by *other* tools, not written in Go, that may have limited > capabilities. Well, if Go doesn't allow you to write libraries usable from other low- lev

Re: print function in python3.1

2009-11-23 Thread Terry Reedy
Dennis Lee Bieber wrote: Does Python 3.x include SQLite? Of course ;-] >>> import sqlite3 >>> dir(sqlite3) ['Binary', 'Cache', 'Connection', 'Cursor', 'DataError', [snip] adapt', 'adapters', 'apilevel', 'complete_statement', 'connect', 'converters', 'datetime', 'dbapi2', 'enable_callback_tr

Re: Don't Understand Error

2009-11-23 Thread Victor Subervi
On Mon, Nov 23, 2009 at 3:18 PM, Carsten Haese wrote: > Victor Subervi wrote: > > [Mon Nov 23 09:52:21 2009] [error] [client 66.248.168.98] Premature end > > of script headers: mailSpreadsheet.py, referer: > > http://globalsolutionsgroup.vi/display_spreadsheet.py > > > > Why? > > A CGI script is e

Re: Python & OpenOffice Spreadsheets

2009-11-23 Thread Terry Reedy
Krishnakant wrote: On Mon, 2009-11-23 at 11:12 +, Paul Rudin wrote: Gerhard Häring writes: Is there a *simple* way to read OpenOffice spreadsheets? Bonus: write them, too? I mean something like: doc.cells[0][0] = "foo" doc.save("xyz.ods") >From a quick look, pyodf offers little more t

sandbox python via module loader

2009-11-23 Thread timprepscius
Greetings, in the past I wrote a sandboxing module loader for c++/ python. I am moving away from python.. I can't stand it actually. Call me blasphemous... I'm immune.. So this code is going to just find the trash.. Maybe it will be useful to someone else. Can't post it all, however, if you ar

Re: Go versus Brand X

2009-11-23 Thread Terry Reedy
Robert Kern wrote: On 2009-11-23 04:47 AM, Antoine Pitrou wrote: Le Mon, 23 Nov 2009 02:36:33 -0600, Robert Kern a écrit : I think there is an overall design sensibility, it's just not a human-facing one. They claim that they designed the syntax to be very easily parsed by very simple tools in

Re: Don't Understand Error

2009-11-23 Thread Carsten Haese
Victor Subervi wrote: > [Mon Nov 23 09:52:21 2009] [error] [client 66.248.168.98] Premature end > of script headers: mailSpreadsheet.py, referer: > http://globalsolutionsgroup.vi/display_spreadsheet.py > > Why? A CGI script is expected to produce output. Your script doesn't produce any output, an

Re: Line-continuation "Anti-Idiom" and with statement

2009-11-23 Thread MRAB
Neil Cerutti wrote: > I installed Python 3.1 today, and I've been porting my small > library of programs to the new system. > > I happened to read the interesting "Idioms and Anti-Idioms" > HOWTO, and saw the '\' continuation character labeled an > anti-idiom. I already generally avoided it, so I

Re: python and netezza

2009-11-23 Thread M.-A. Lemburg
Shan wrote: > Is there any module in python to connect with netezza database?(like > cx_Oracle which is used to connect Oracle from python) You can use our mxODBC database adapters together with the Netezza ODBC drivers. For single-tier setups (client application and database on the same server o

Re: Switching Databases

2009-11-23 Thread Terry Reedy
Victor Subervi wrote: A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred. [snip hmtl error report] Please post plain text - ascii or utf8. On my newsreader, what you posted, with a mismash of colors, bold, italic,

Re: Line Breaks

2009-11-23 Thread Susan Day
On Mon, Nov 23, 2009 at 2:26 PM, Gary Herron wrote: > >>> print 'A Message From %s:\n\n %s' % ('someone','some message') > A Message From someone: > > some message > > > So... *Exactly* what are you doing with msg, and *exactly* what is your > evidence that line breaks are being ignored. With th

Re: Minimally intrusive XML editing using Python

2009-11-23 Thread Nobody
On Mon, 23 Nov 2009 17:45:24 +0100, Thomas Lotze wrote: >> What's your real problem, or use case? Are you just concerned with >> diffing, or are others likely to read the xml, and want it formatted the >> way it already is? > > I'd like to put the XML under revision control along with other st

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread Stephen Hansen
On Mon, Nov 23, 2009 at 11:14 AM, astral orange <457r0...@gmail.com> wrote: > But back to the example, on line 104 I see there's a call to the > lookup function, passing 3 > parameters ('data', which I think is a nested dictionary, label > (first, middle, last) and name). > > But I am getting lo

Re: [repost please help me] python setup.py build for 32-bits on x86_64 machine

2009-11-23 Thread Sérgio Monteiro Basto
Diez B. Roggisch wrote: Hi, Thanks, > Sérgio Monteiro Basto wrote: > >> Hi, >> I am in x86_64 arch , but I need >> compile things on 32 bits with >> python setup.py build >> >> Can't change the fact that distutils creates x86_64 >> directories: >> build/temp.linux-x86_64-2.3/ >> >> Also if I tr

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread Stephen Hansen
On Mon, Nov 23, 2009 at 10:26 AM, j wrote: > What I am not totally sure about is when the store function callsthe > lookup function and does "return data[label].get(name)", that line > "trips" me up somethen the lookup function returns that back to > the store function, assigns the data to th

Re: Line Breaks

2009-11-23 Thread Gary Herron
Susan Day wrote: Hi; I have the following line of code I'm sending to postfix: msg = 'A Message From %s:\n\n %s' % (string.replace(customer, '_', ' '), msg) Unfortunately, it ignores the line breaks. I also tried %0A but that was ignored also. Please advise. TIA, Suzie That line does no

IDE+hg

2009-11-23 Thread NiklasRTZ
Dear experts, Since no py IDE I found has easy hg access. IDEs PIDA and Eric claim Mercurial support not found i.e. buttons to clone, commit and push to repositories to define dev env dvcs, editor and deployment all in 1. I tested Boa Constructor, dr Python, Eric and PIDA none of which has other th

Re: Line Breaks

2009-11-23 Thread Stephen Hansen
On Mon, Nov 23, 2009 at 10:45 AM, Susan Day wrote: > Hi; > I have the following line of code I'm sending to postfix: > > msg = 'A Message From %s:\n\n %s' % (string.replace(customer, '_', ' '), > msg) > > Unfortunately, it ignores the line breaks. I also tried %0A but that was > ignored also. Pl

Read IDL save files into Python

2009-11-23 Thread Thomas Robitaille
I would like to briefly advertise the 0.9.2 release of IDLSave, a package I recently developed to read IDL save files into Python. Installation instructions are available at http://idlsave.sourceforge.net/. Please do not hesitate to submit a bug report if you run into any problems! Cheers, Thomas

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread astral orange
On Nov 23, 1:17 pm, "Diez B. Roggisch" wrote: > astral orange wrote: > > Hi, I am trying to teach myself Python and have a good book to help me > > but I am stuck on something and I would like for someone to explain > > the following piece of code for me and what it's actually doing. > > Certain p

Line-continuation "Anti-Idiom" and with statement

2009-11-23 Thread Neil Cerutti
I installed Python 3.1 today, and I've been porting my small library of programs to the new system. I happened to read the interesting "Idioms and Anti-Idioms" HOWTO, and saw the '\' continuation character labeled an anti-idiom. I already generally avoided it, so I just nodded. Unfortunately, the

Re: Beginning Question about Python functions, parameters...

2009-11-23 Thread MRAB
j wrote: On Nov 23, 12:37 pm, Neo wrote: astral orange schrieb: Hi, I am trying to teach myself Python and have a good book to help me but I am stuck on something and I would like for someone to explain the following piece of code for me and what it's actually doing. Certain parts are very

Line Breaks

2009-11-23 Thread Susan Day
Hi; I have the following line of code I'm sending to postfix: msg = 'A Message From %s:\n\n %s' % (string.replace(customer, '_', ' '), msg) Unfortunately, it ignores the line breaks. I also tried %0A but that was ignored also. Please advise. TIA, Suzie -- http://mail.python.org/mailman/listinf

  1   2   >