Re: Yet another unicode WTF

2009-06-04 Thread Gabriel Genellina
En Thu, 04 Jun 2009 22:18:24 -0300, Ron Garret escribió: Python 2.6.2 on OS X 10.5.7: [...@mickey:~]$ echo $LANG en_US.UTF-8 [...@mickey:~]$ cat frob.py #!/usr/bin/env python print u'\u03BB' [...@mickey:~]$ ./frob.py ª [...@mickey:~]$ ./frob.py > foo Traceback (most recent call last): Fil

Re: Yet another unicode WTF

2009-06-04 Thread Ron Garret
In article , Lawrence D'Oliveiro wrote: > In message , Ron > Garret wrote: > > > Python 2.6.2 on OS X 10.5.7: > > Same result, Python 2.6.1-3 on Debian Unstable. My $LANG is en_NZ.UTF-8. > > > ... I always thought one of the fundamental > > invariants of unix processes was that there's no wa

Re: Yet another unicode WTF

2009-06-04 Thread Ben Finney
Ron Garret writes: > Python 2.6.2 on OS X 10.5.7: > > [...@mickey:~]$ echo $LANG > en_US.UTF-8 > [...@mickey:~]$ cat frob.py > #!/usr/bin/env python > print u'\u03BB' > > [...@mickey:~]$ ./frob.py > ª > [...@mickey:~]$ ./frob.py > foo > Traceback (most recent call last): > File "./frob.py",

Re: How do I continue after the error?

2009-06-04 Thread Ben Finney
Ben Finney writes: > You achieve this by one of two methods: Failed to update this statement after an edit. That should be “by following this method”. -- \ “I used to be a proofreader for a skywriting company.” —Steven | `\Wri

Re: __file__ access extremely slow

2009-06-04 Thread Steven D'Aprano
On Thu, 04 Jun 2009 18:24:48 -0700, Zac Burns wrote: > The section of code below, which simply gets the __file__ attribute of > the imported modules, takes more than 1/3 of the total startup time. How do you know? What are you using to time it? [...] > From once python starts and loads the main

Re: Yet another unicode WTF

2009-06-04 Thread Benjamin Kaplan
On Thu, Jun 4, 2009 at 10:06 PM, Ben Finney > wrote: > Ron Garret writes: > > > Python 2.6.2 on OS X 10.5.7: > > > > [...@mickey:~]$ echo $LANG > > en_US.UTF-8 > > [...@mickey:~]$ cat frob.py > > #!/usr/bin/env python > > print u'\u03BB' > > > > [...@mickey:~]$ ./frob.py > > ª > > [...@mickey:~]

Re: import _sqlite3 no module named error

2009-06-04 Thread Ned Deily
In article <77e831100906041718k4b4f54d9v29729449c50f...@mail.gmail.com>, Vincent Davis wrote: > On Thu, Jun 4, 2009 at 1:41 PM, Ned Deily wrote: >[...] > > $ /opt/local/bin/python2.5 > > Python 2.5.4 (r254:67916, May  4 2009, 01:40:08) > > [GCC 4.0.1 (Apple Inc. build 5490)] on darwin > > Type

Re: __file__ access extremely slow

2009-06-04 Thread Gabriel Genellina
En Thu, 04 Jun 2009 22:24:48 -0300, Zac Burns escribió: The section of code below, which simply gets the __file__ attribute of the imported modules, takes more than 1/3 of the total startup time. Given that many modules are complicated and even have dynamic population this figure seems very hig

Re: Odd closure issue for generators

2009-06-04 Thread Michele Simionato
On Jun 5, 1:18 am, Carl Banks wrote: > It's really the only sane way to handle it, odd though it may seem in > this narrow case.  In Python nested functions have to be able to > reference the current value of a variable because of use cases like > this: > > def func(): >     def printx(): >      

Re: How do I continue after the error?

2009-06-04 Thread Steven D'Aprano
On Thu, 04 Jun 2009 18:26:49 -0700, chad wrote: > Let's say I have a list of 5 files. Now lets say that one of the files > reads nude333.txt instead of nude3.txt. When this happens, the program > generates an error and quits. What I want it to do is just skip over the > bad file and continue on wi

Re: __file__ access extremely slow

2009-06-04 Thread Steven D'Aprano
On Fri, 05 Jun 2009 02:21:07 +, Steven D'Aprano wrote: > You corrected this to: > > for module in sys.modules.itervalues(): >try: >path = module.__file__ >except (AttributeError, ImportError): >return > > (1) You're not importing anything insid

urlretrieve() failing on me

2009-06-04 Thread Robert Dailey
Hey guys, try using urlretrieve() in Python 3.0.1 on the following URL: http://softlayer.dl.sourceforge.net/sourceforge/wxwindows/wxMSW-2.8.10.zip Have it save the ZIP to any destination directory. For me, this only downloads about 40KB before it stops without any error at all. Any reason why thi

Re: __file__ access extremely slow

2009-06-04 Thread Terry Reedy
Zac Burns wrote: The section of code below, which simply gets the __file__ attribute of the imported modules, takes more than 1/3 of the total startup time. Given that many modules are complicated and even have dynamic population this figure seems very high to me. it would seem very high if one j

Re: Yet another unicode WTF

2009-06-04 Thread Ned Deily
In article , Ron Garret wrote: > Python 2.6.2 on OS X 10.5.7: > > [...@mickey:~]$ echo $LANG > en_US.UTF-8 > [...@mickey:~]$ cat frob.py > #!/usr/bin/env python > print u'\u03BB' > > [...@mickey:~]$ ./frob.py > ª > [...@mickey:~]$ ./frob.py > foo > Traceback (most recent call last): > File

Re: Feedparser problem

2009-06-04 Thread Aahz
In article <89d21aec-5d39-4d1f-91b9-776da3506...@i6g2000yqj.googlegroups.com>, Jonathan Nelson wrote: > >I'm trying to add a feedreader element to my django project. I'm >using Mark Pilgrim's great feedparser library. I've used it before >without any problems. I'm getting a TypeError I can't f

Re: __file__ access extremely slow

2009-06-04 Thread John Machin
Steven D'Aprano REMOVE.THIS.cybersource.com.au> writes: > > On Fri, 05 Jun 2009 02:21:07 +, Steven D'Aprano wrote: > > > You corrected this to: > > > > for module in sys.modules.itervalues(): > >try: > >path = module.__file__ > >except (AttributeError, Impor

How to develop a python application?

2009-06-04 Thread Vincent Davis
This might be a off topic but this also seemed like a good place to ask. I have an application (several) I would like to develop. Parts of it I can do but parts I would like to outsource. I am thinking mostly of outsourcing most of my django (or similar) work and otherwise have some custom classes

Re: How do I continue after the error?

2009-06-04 Thread chad
On Jun 4, 7:36 pm, Steven D'Aprano wrote: > On Thu, 04 Jun 2009 18:26:49 -0700, chad wrote: > > Let's say I have a list of 5 files. Now lets say that one of the files > > reads nude333.txt instead of nude3.txt. When this happens, the program > > generates an error and quits. What I want it to do i

Re: Odd closure issue for generators

2009-06-04 Thread Brian Quinlan
Scott David Daniels wrote: [snipped] When you evaluate a lambda expression, the default args are evaluated, but the expression inside the lambda body is not. When you apply that evaluated lambda expression, the expression inside the lambda body is is evaluated and returned. But that's not real

Re: Generating all combinations

2009-06-04 Thread Steven D'Aprano
On Thu, 04 Jun 2009 09:47:05 -0700, Mensanator wrote: > After all, everybody knows that for m items taken n at a time, the > counts are > > perm w/repl = m**n > comb w/repl = (m+n-1)!/(n!(m-1)!) > perm wo/repl = m!/(m-n)! > comb wo/repl = m!/(n!(m-n)!) "Everybody" knows? Be careful with those

Re: Yet another unicode WTF

2009-06-04 Thread Ben Finney
Ned Deily writes: > $ python2.6 -c 'import sys; print sys.stdout.encoding, \ > sys.stdout.isatty()' > UTF-8 True > $ python2.6 -c 'import sys; print sys.stdout.encoding, \ > sys.stdout.isatty()' > foo ; cat foo > None False So shouldn't the second case also detect UTF-8? The filesystem knows i

Re: Project source code layout?

2009-06-04 Thread Dave Angel
Lawrence D'Oliveiro wrote: In message , Allen Fowler wrote: 1) Do you use virtualpython? No idea what that is. 2) How do you load the modules in your lib directory? At the beginning of my scripts, I have a sequence like test_mode = False # True for testing, False for

Re: Odd closure issue for generators

2009-06-04 Thread Dave Angel
Carl Banks wrote: The way to handle the issue you are seeing is to create a new scope with a variable the remains at the value you want to close upon: create_const_function(value): def func(): return value c =create_const_function(i) for i in range(11, 16)) Or you can do it the sl

how to iterate over several lists?

2009-06-04 Thread kj
Suppose I have two lists, list_a and list_b, and I want to iterate over both as if they were a single list. E.g. I could write: for x in list_a: foo(x) for x in list_b: foo(x) But is there a less cumbersome way to achieve this? I'm thinking of something in the same vein as Perl's: fo

Re: how to iterate over several lists?

2009-06-04 Thread Chris Rebert
On Thu, Jun 4, 2009 at 9:07 PM, kj wrote: > > > Suppose I have two lists, list_a and list_b, and I want to iterate > over both as if they were a single list.  E.g. I could write: > > for x in list_a: >    foo(x) > for x in list_b: >    foo(x) > > But is there a less cumbersome way to achieve this?

Re: how to get the path of a module (myself) ?

2009-06-04 Thread Steven D'Aprano
On Wed, 03 Jun 2009 01:00:15 +0200, Stef Mientki wrote: > Sorry, > but I realy don't understand the difference between the documents on my > desk and a python file in a subpath. Let's say you have a file called "parrot", containing some arbitrary data. You read it with open('parrot').read(), and

Re: how to iterate over several lists?

2009-06-04 Thread Ben Finney
Chris Rebert writes: > On Thu, Jun 4, 2009 at 9:07 PM, kj wrote: > > > > > > Suppose I have two lists, list_a and list_b, and I want to iterate > > over both as if they were a single list. […] > Just add the lists together. > > for x in list_a + list_b: > foo(x) Which, more precisely, crea

Re: import sqlite3

2009-06-04 Thread Mark Tolonen
"willgun" wrote in message news:h08c5e$au...@news.cn99.com... By the way ,what does 'best regards' means at the end of a mail? I think 恭祝 may be a good translation. -Mark -- http://mail.python.org/mailman/listinfo/python-list

Re: Printing list/tuple elements on separate lines

2009-06-04 Thread John Yeung
On Jun 4, 8:37 pm, Johnny Chang wrote: > I have a large list of strings that I am unpacking > and splitting, and I want each one to be on a new line. > > An example: > > recs = > 'asdfasdfasdfasdfasdf','asdfasdfasdfasdfasdf','asdfasdfasdfasdfasdf' > [(rec.split('f')) for rec in recs] > > output: >

Re: Printing list/tuple elements on separate lines

2009-06-04 Thread Daniel Fetchinson
>> I have a large list of strings that I am unpacking >> and splitting, and I want each one to be on a new line. >> >> An example: >> >> recs = >> 'asdfasdfasdfasdfasdf','asdfasdfasdfasdfasdf','asdfasdfasdfasdfasdf' >> [(rec.split('f')) for rec in recs] >> >> output: >> >> [['asd', 'asd', 'asd', 'a

Re: Odd closure issue for generators

2009-06-04 Thread Aahz
In article <05937a34-5490-4b31-9f07-a319b44dd...@r33g2000yqn.googlegroups.com>, Michele Simionato wrote: > >Actually, in Scheme one would have to fight to define >a list comprehension (more in general loops) working as >in Python: the natural definition works as the OP wants. See >http://www.arti

Re: how to iterate over several lists?

2009-06-04 Thread Stefan Behnel
kj wrote: > Suppose I have two lists, list_a and list_b, and I want to iterate > over both as if they were a single list. E.g. I could write: > > for x in list_a: > foo(x) > for x in list_b: > foo(x) > > But is there a less cumbersome way to achieve this? Take a look at the itertools mo

Re: Project source code layout?

2009-06-04 Thread Lawrence D'Oliveiro
In message , Dave Angel wrote: > Rather than editing the source files at install time, consider just > using an environment variable in your testing environment, which would > be missing in production environment. I'd still need to define that environment variable in a wrapper script, which mea

Re: Yet another unicode WTF

2009-06-04 Thread Lawrence D'Oliveiro
In message , Gabriel Genellina wrote: > Python knows the terminal encoding (or at least can make a good guess), > but a file may use *any* encoding you want, completely unrelated to your > terminal settings. It should still respect your localization settings, though. -- http://mail.python.org/

Re: python way to automate IE8's File Download dialog

2009-06-04 Thread Lawrence D'Oliveiro
In message <4f4f3e86-170a-4ad9-934d-4fa5b7d23...@n4g2000vba.googlegroups.com>, monogeo wrote: > I am able to use PAMIE 2.0 to automate IE7's File Download dialog, but > the same approach/code fails on IE8. I don't understand why you need to automate a GUI front-end, meant for human use, to a f

Re: Project source code layout?

2009-06-04 Thread Lawrence D'Oliveiro
In message , Jean-Paul Calderone wrote: > On Thu, 04 Jun 2009 21:33:13 +1200, Lawrence D'Oliveiro > wrote: > >>In message , Allen >>Fowler wrote: >> >>> I was hoping to keep the dev layout as close to deployment possible. >> >>Completely different purposes. For example, the actual production dat

Re: ctype question

2009-06-04 Thread Thomas Heller
Amit Gupta schrieb: > Hi, > > I have been using ctype.cdll to load a library, but I am unable to > figure out how to load multiple libraries that depends on each other. > E.g. I have two libraries A.so and B.so. A.so has some undefined > references, and those symbols are defined in B.so. > > When

Re: Odd closure issue for generators

2009-06-04 Thread Ned Deily
In article <4a28903b.4020...@sweetapp.com>, Brian Quinlan wrote: > Scott David Daniels wrote: > [snipped] > > When you evaluate a lambda expression, the default args are evaluated, > > but the expression inside the lambda body is not. When you apply that > > evaluated lambda expression, the expr

Re: The Complexity And Tedium of Software Engineering

2009-06-04 Thread Xah Lee
On Jun 3, 11:50 pm, Xah Lee wrote: > Of interest: > • The Complexity And Tedium of Software Engineering > http://xahlee.org/UnixResource_dir/writ/programer_frustration.html Addendum: The point in these short examples is not about software bugs or problems. It illustrates, how seemingly trivial

Re: Generating all combinations

2009-06-04 Thread Mensanator
On Jun 4, 10:25�pm, Steven D'Aprano wrote: > On Thu, 04 Jun 2009 09:47:05 -0700, Mensanator wrote: > > After all, everybody knows that for m items taken n at a time, the > > counts are > > > perm �w/repl = m**n > > comb �w/repl = (m+n-1)!/(n!(m-1)!) > > perm wo/repl = m!/(m-n)! > > comb wo/repl =

Re: Yet another unicode WTF

2009-06-04 Thread Ben Finney
"Gabriel Genellina" writes: > Python knows the terminal encoding (or at least can make a good > guess), but a file may use *any* encoding you want, completely > unrelated to your terminal settings. It may, yes, and the programmer is free to specify any encoding. > So when stdout is redirected,

Re: Odd closure issue for generators

2009-06-04 Thread Lawrence D'Oliveiro
In message , Brian Quinlan wrote: >>>> c = (lambda : i for i in range(11, 16)) >>>> d = list(c) >>>> for q in d: >...print(q()) >... >15 >15 >15 >15 >15 Try >>> c = ((lambda i : lambda : i)(i) for i in range(11, 16)) >>> d = list(c) >>

<    1   2