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) >>

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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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: 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 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?

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: 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

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: 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: 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: 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: 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

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: __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

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: 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: __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

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 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

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: 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: __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: 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: 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: __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: 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: 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: 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 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: How do I continue after the error?

2009-06-04 Thread Ben Finney
chad writes: > 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 with the next one. Have you worked

Re: Yet another unicode WTF

2009-06-04 Thread Ben Finney
Ron Garret writes: > According to what I thought I knew about unix (and I had fancied myself > a bit of an expert until just now) this is impossible. Python is > obviously picking up a different default encoding when its output is > being piped to a file, but I always thought one of the funda

Re: 2d barcode library?

2009-06-04 Thread Trevor
> > Christian > > [1]https://cybernetics.hudora.biz/projects/wiki/huBarcode Thanks guys! huBarcode will work.. -- http://mail.python.org/mailman/listinfo/python-list

Re: Yet another unicode WTF

2009-06-04 Thread Lawrence D'Oliveiro
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 way for a process to > know what's on the other end of its stdo

Re: Making the case for repeat

2009-06-04 Thread Gabriel Genellina
En Thu, 04 Jun 2009 10:37:45 -0300, pataphor escribió: So here is my proposed suggestion for a once and for all reconciliation of various functions in itertools that can not stand on their own and keep a straight face. Because of backwards compatibility issues we cannot remove them but we can b

Re: unladen swallow: python and llvm

2009-06-04 Thread Jesse Noller
You can email these questions to the unladen-swallow mailing list. They're very open to answering questions. 2009/6/4 Luis M. González : > I am very excited by this project (as well as by pypy) and I read all > their plan, which looks quite practical and impressive. > But I must confess that I can

Re: What text editor is everyone using for Python

2009-06-04 Thread greg
Albert van der Horst wrote: Memories of Atari 260/520/1040 that had a keyboard with a key actually marked ... HELP. Modern day Mac keyboards have one of those, too. -- Greg -- http://mail.python.org/mailman/listinfo/python-list

Re: Odd closure issue for generators

2009-06-04 Thread Brian Quinlan
Gabriel Genellina wrote: En Thu, 04 Jun 2009 18:40:07 -0300, Brian Quinlan escribió: This is from Python built from the py3k branch: It's not new; same thing happens with 2.x A closure captures (part of) the enclosing namespace, so names are resolved in that environment even after the enc

How do I continue after the error?

2009-06-04 Thread chad
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 with the next one. Below is the actual code. It only works

Re: __file__ access extremely slow

2009-06-04 Thread Zac Burns
Sorry, there is a typo. The code should read as below to repro the problem: for module in sys.modules.itervalues(): try: path = module.__file__ except (AttributeError, ImportError): return

ctype question

2009-06-04 Thread Amit Gupta
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 I try to load ctypes.cdll.LoadLibra

Re: What text editor is everyone using for Python

2009-06-04 Thread Ben Finney
Emile van Sebille writes: > On 6/4/2009 3:19 PM Lawrence D'Oliveiro said... > > In message , Nick Craig- > > Wood wrote: > > > >> You quit emacs with Ctrl-X Ctrl-C. > > > > That's "save-buffers-kill-emacs". If you don't want to save buffers, > > the exit sequence is alt-tilde, f, e. This is an i

__file__ access extremely slow

2009-06-04 Thread Zac Burns
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 just considered the

Yet another unicode WTF

2009-06-04 Thread Ron Garret
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", line 2, in print u'\u03BB' UnicodeEncodeE

Re: What text editor is everyone using for Python

2009-06-04 Thread Emile van Sebille
On 6/4/2009 3:19 PM Lawrence D'Oliveiro said... In message , Nick Craig- Wood wrote: You quit emacs with Ctrl-X Ctrl-C. That's "save-buffers-kill-emacs". If you don't want to save buffers, the exit sequence is alt-tilde, f, e. Ha ha ha ha ha! No -- really? Emile -- http://mail.python.o

unladen swallow: python and llvm

2009-06-04 Thread Luis M . González
I am very excited by this project (as well as by pypy) and I read all their plan, which looks quite practical and impressive. But I must confess that I can't understand why LLVM is so great for python and why it will make a difference. AFAIK, LLVM is alot of things at the same time (a compiler inf

Re: Printing list/tuple elements on separate lines

2009-06-04 Thread Stephen Hansen
On Thu, Jun 4, 2009 at 5: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. Someone showed me how to do it > and I got it working, except it is not printing each on its own > separate line as his did, making i

Printing list/tuple elements on separate lines

2009-06-04 Thread Johnny Chang
I have a large list of strings that I am unpacking and splitting, and I want each one to be on a new line. Someone showed me how to do it and I got it working, except it is not printing each on its own separate line as his did, making it incredibly hard to read. He did it without adding a new lin

Re: import _sqlite3 no module named error

2009-06-04 Thread Vincent Davis
On Thu, Jun 4, 2009 at 1:41 PM, Ned Deily wrote: > In article > <77e831100906041151g70868dbre1546cdb01082...@mail.gmail.com>, >  Vincent Davis wrote: >> Yes I am using macports I think sqlite is installed? here is what I >> get when I run >> sudo port install py25-sqlite3 >> >> vincent-daviss-mac

Re: easiest way to plot x,y graphically during run-time?

2009-06-04 Thread Esmail
Peter Pearson wrote: On Thu, 04 Jun 2009 03:29:42 -0500, Nick Craig-Wood wrote: [snip] Here is a demo with pygame... [snip] And just for completeness, here is a demo with PyGUI, written in similar style. Thanks for this too! Esmail -- http://mail.python.org/mailman/listinfo/python-list

Re: easiest way to plot x,y graphically during run-time?

2009-06-04 Thread Esmail
Scott David Daniels wrote: Esmail wrote: Scott David Daniels wrote: Esmail wrote: ... Tk seems a bit more complex .. but I really don't know much about it and its interface with Python to make any sort of judgments as to which option would be better. This should look pretty easy: Thanks Sc

Re: easiest way to plot x,y graphically during run-time?

2009-06-04 Thread Esmail
Nick Craig-Wood wrote: Here is a demo with pygame... Thanks Nick, I'll be studying this too :-) Esmail -- http://mail.python.org/mailman/listinfo/python-list

Re: Odd closure issue for generators

2009-06-04 Thread Scott David Daniels
Brian Quinlan wrote: This is from Python built from the py3k branch: >>> c = (lambda : i for i in range(11, 16)) >>> for q in c: ... print(q()) ... 11 12 13 14 15 >>> # This is expected >>> c = (lambda : i for i in range(11, 16)) >>> d = list(c) >>> for q in d: ... print(q()) ... 15

Re: easiest way to plot x,y graphically during run-time?

2009-06-04 Thread Peter Pearson
On Thu, 04 Jun 2009 03:29:42 -0500, Nick Craig-Wood wrote: [snip] > Here is a demo with pygame... [snip] And just for completeness, here is a demo with PyGUI, written in similar style. (I'm a PyGUI newbie, so constructive criticism would be appreciated.) from GUI import Window, View, application

Re: Odd closure issue for generators

2009-06-04 Thread Carl Banks
On Jun 4, 2:40 pm, Brian Quinlan wrote: > This is from Python built from the py3k branch: >  >>> c = (lambda : i for i in range(11, 16)) >  >>> for q in c: > ...     print(q()) > ... > 11 > 12 > 13 > 14 > 15 >  >>> # This is expected >  >>> c = (lambda : i for i in range(11, 16)) >  >>> d = list(c

Re: Using C++ and ctypes together: a vast conspiracy? ;)

2009-06-04 Thread Scott David Daniels
Joseph Garvin wrote: On Thu, Jun 4, 2009 at 2:35 PM, Thomas Heller wrote: [Please keep the discussion on the list] All in all, as I said, IMO it is too complicated to figure out the binary layout of the C++ objects (without using a C++ compiler), also there are quite some Python packages for a

Re: Odd closure issue for generators

2009-06-04 Thread Gabriel Genellina
En Thu, 04 Jun 2009 18:40:07 -0300, Brian Quinlan escribió: This is from Python built from the py3k branch: It's not new; same thing happens with 2.x A closure captures (part of) the enclosing namespace, so names are resolved in that environment even after the enclosing block has finishe

Re: "where" in python

2009-06-04 Thread Robert Kern
On 2009-06-04 12:53, Chris wrote: I am a newby in Python and I'm first looking for equivalent to things I already manage: IDL. For example, I want to plot a sub-set of points, selected from a bigger set by applying some filter. In my example, I want to select only the values> 0. I succeed to wri

Re: Project source code layout?

2009-06-04 Thread Lawrence D'Oliveiro
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 production if test_mode : home_

Re: What text editor is everyone using for Python

2009-06-04 Thread Lawrence D'Oliveiro
In message , Albert van der Horst wrote: > Memories of Atari 260/520/1040 that had a keyboard with a key actually > marked ... HELP. And the OLPC machines have a key marked "reveal source". -- http://mail.python.org/mailman/listinfo/python-list

Re: Using C++ and ctypes together: a vast conspiracy? ;)

2009-06-04 Thread Joseph Garvin
On Thu, Jun 4, 2009 at 2:35 PM, Thomas Heller wrote: > [Please keep the discussion on the list] > > All in all, as I said, IMO it is too complicated to figure out the binary > layout of the C++ objects (without using a C++ compiler), also there are > quite some Python packages for accessing them.

Re: What text editor is everyone using for Python

2009-06-04 Thread Lawrence D'Oliveiro
In message , Nick Craig- Wood wrote: > You quit emacs with Ctrl-X Ctrl-C. That's "save-buffers-kill-emacs". If you don't want to save buffers, the exit sequence is alt-tilde, f, e. -- http://mail.python.org/mailman/listinfo/python-list

Re: Using C++ and ctypes together: a vast conspiracy? ;)

2009-06-04 Thread Joseph Garvin
On Thu, Jun 4, 2009 at 3:23 PM, Brian wrote: > What is the goal of this conversation that goes above and beyond what > Boost.Python + pygccxml achieve? I can't speak for others but the reason I was asking is because it's nice to be able to define bindings from within python. At a minimum, compili

Odd closure issue for generators

2009-06-04 Thread Brian Quinlan
This is from Python built from the py3k branch: >>> c = (lambda : i for i in range(11, 16)) >>> for q in c: ... print(q()) ... 11 12 13 14 15 >>> # This is expected >>> c = (lambda : i for i in range(11, 16)) >>> d = list(c) >>> for q in d: ... print(q()) ... 15 15 15 15 15 >>> # I was ver

MultiReplace (performance and unordered dicts)

2009-06-04 Thread Joseph Reagle
I have programs that do lots of string-to-string replacements, so I'm trying to create a speedy implementation (tons of .replace statements has become unwieldy). My MultiReplace object does as well as the function regexp, which both do better than the for loop function, any other suggestions? def

Re: Illegal seek with os.popen

2009-06-04 Thread Aahz
[posted & e-mailed] In article <5edde6ee-4446-4f53-91ee-ad3aea4b5...@q37g2000vbi.googlegroups.com>, wrote: > >Python 3.0.1 (r301:69556, Jun 4 2009, 16:07:22) [C] on aix5 >Type "help", "copyright", "credits" or "license" for more information. import os os.popen('cat','w') > > >So it se

Re: Using C++ and ctypes together: a vast conspiracy? ;)

2009-06-04 Thread Brian
Just to expound a bit on pygccxml, which really makes boost worth it. pygccxml enables you to do all of your binding work from within Python. It calls gccxml, which is an xml backend to gcc that outputs the parse tree in an xml format. Pygccxml provides a very high level interface between the gcc x

Re: Using C++ and ctypes together: a vast conspiracy? ;)

2009-06-04 Thread Brian
Well you'll just have to try Boost.Python. There is a pygccxml gui gets you started in about 15 minutes. You'll be able to see how well it groks your code and what that generated code is. Boost is the best. People complain about it because they don't understand C++ templates and they don't realize

Re: Using C++ and ctypes together: a vast conspiracy? ;)

2009-06-04 Thread Philip Semanchuk
On Jun 4, 2009, at 4:23 PM, Brian wrote: What is the goal of this conversation that goes above and beyond what Boost.Python + pygccxml achieve? Boost has published a variety of libraries that will be included into the next c++ standard. It's hard to imagine a better designed python/c++ inte

Re: multi-core software

2009-06-04 Thread MRAB
Kaz Kylheku wrote: ["Followup-To:" header set to comp.lang.lisp.] On 2009-06-04, Roedy Green wrote: On Thu, 4 Jun 2009 09:46:44 -0700 (PDT), Xah Lee wrote, quoted or indirectly quoted someone who said : • Why Must Software Be Rewritten For Multi-Core Processors? Threads have been part of Ja

Re: Illegal seek with os.popen

2009-06-04 Thread Terry Reedy
prueba...@latinmail.com wrote: Python 3.0.1 (r301:69556, Jun 4 2009, 16:07:22) [C] on aix5 Type "help", "copyright", "credits" or "license" for more information. import os os.popen('cat','w') So it seems to be something in 3.1 that causes it to fail. BTW it is not like I use os.popen a lot.

Re: What text editor is everyone using for Python

2009-06-04 Thread Nick Craig-Wood
Steven D'Aprano wrote: > On Tue, 02 Jun 2009 10:54:48 +1200, Lawrence D'Oliveiro wrote: > > > In message , Albert van der Horst wrote: > > > >> An indication of how one can see one is in emacs is also appreciated. > > > > How about, hit CTRL/G and see if the word "Quit" appears somewhere. > >

Re: Using C++ and ctypes together: a vast conspiracy? ;)

2009-06-04 Thread Brian
What is the goal of this conversation that goes above and beyond what Boost.Python + pygccxml achieve? Boost has published a variety of libraries that will be included into the next c++ standard. It's hard to imagine a better designed python/c++ interface library than Boost.Python. Further, pygccxm

Re: Illegal seek with os.popen

2009-06-04 Thread pruebauno
On Jun 3, 3:36 pm, a...@pythoncraft.com (Aahz) wrote: > In article > <7c93031a-235e-4e13-bd37-7c9dbc6e8...@r16g2000vbn.googlegroups.com>, > > > >   wrote: > >Should I open a bug report for this? > > >Python 2.5.1 (r251:54863, Sep 19 2007, 14:58:06) [C] on aix5 > >Type "help", "copyright", "credits

Re: import sqlite3

2009-06-04 Thread Gabriel Genellina
En Thu, 04 Jun 2009 03:14:18 -0300, willgun escribió: I'm a student from China.It's painful for us to read python documentation entirely due to poor english.So I often make these mistakes. Try "chinese python group" at Google - I see some promising results at least... -- Gabriel Genell

Re: Using C++ and ctypes together: a vast conspiracy? ;)

2009-06-04 Thread Thomas Heller
Philip Semanchuk schrieb: > Hi Thomas, > We're weighing options for accessing C++ objects via Python. I know of > SIWG and Boost; are there others that you think deserve consideration? I haven't used any of them myself. A common suggestion is SIP, less known are pybindgen and Robin. But there

Re: Using C++ and ctypes together: a vast conspiracy? ;)

2009-06-04 Thread Philip Semanchuk
On Jun 4, 2009, at 3:35 PM, Thomas Heller wrote: [Please keep the discussion on the list] Joseph Garvin schrieb: On Thu, Jun 4, 2009 at 3:43 AM, Thomas Heller wrote: There have been some attempts to use ctypes to access C++ objects. We (Roman Yakovenko and myself) made some progress. We w

Is socket.shutdown(1) useless

2009-06-04 Thread Mohamed Garrana
Hello This is is in answer for Is socket.shutdown(1) useless Shutdown(1) , forces the socket no to send any more data This is usefull in Buffer flushing Strange error detection Safe guarding Let me explain more , when you send a data , it's not guaranteed to be sent to your peer , it's only

Re: import _sqlite3 no module named error

2009-06-04 Thread Ned Deily
In article <77e831100906041151g70868dbre1546cdb01082...@mail.gmail.com>, Vincent Davis wrote: > Yes I am using macports I think sqlite is installed? here is what I > get when I run > sudo port install py25-sqlite3 > > vincent-daviss-macbook-pro-2:~ vmd$ sudo port install py25-sqlite3 > Skipping

Re: Using C++ and ctypes together: a vast conspiracy? ;)

2009-06-04 Thread Thomas Heller
[Please keep the discussion on the list] Joseph Garvin schrieb: > On Thu, Jun 4, 2009 at 3:43 AM, Thomas Heller wrote: >> There have been some attempts to use ctypes to access C++ objects. >> We (Roman Yakovenko and myself) made some progress. We were able to >> handle C++ name mangling, the spe

Re: multi-core software

2009-06-04 Thread Kaz Kylheku
["Followup-To:" header set to comp.lang.lisp.] On 2009-06-04, Roedy Green wrote: > On Thu, 4 Jun 2009 09:46:44 -0700 (PDT), Xah Lee > wrote, quoted or indirectly quoted someone who said : > >>• Why Must Software Be Rewritten For Multi-Core Processors? > > Threads have been part of Java since Day

Re: import _sqlite3 no module named error

2009-06-04 Thread Vincent Davis
>> when I try to run his app I get the no module named _sqlite3 , I am >> not sure what this is caused by as it looks to me like sqlite3 is >> trying to import it. Any idea how to fix this? Other than the obvious >> of getting _sqlite3 somehow, or maby it is that simple >>   >> "/opt/local/Librar

Re: import _sqlite3 no module named error

2009-06-04 Thread Ned Deily
In article <77e831100906040708l1a8bf638n19bbff05607b3...@mail.gmail.com>, Vincent Davis wrote: > I volunteered to help Marijo Mihelčić who was looking for someone with > a mac the help him build a mac binary using py2app for his > simpletasktimer > http://code.google.com/p/simpletasktimer/wiki/

Re: Get the hard disk hardware serial number

2009-06-04 Thread Paul Boddie
On 4 Jun, 11:29, Nick Craig-Wood wrote: > > For linux I'd run this and parse the results. > > # smartctl -i /dev/sda Also useful is hdparm, particularly with the drive identification and detailed information options shown respectively below: # hdparm -i /dev/sda # hdparm -I /dev/sda Paul -- ht

Re: Winter Madness - Passing Python objects as Strings

2009-06-04 Thread Nigel Rantor
Hendrik van Rooyen wrote: It is not something that would find common use - in fact, I have never, until I started struggling with my current problem, ever even considered the possibility of converting a pointer to a string and back to a pointer again, and I would be surprised if anybody else on

Re: Get the hard disk hardware serial number

2009-06-04 Thread Terry Reedy
Dietmar Schwertberger wrote: The WMI method is e.g. described here: http://www.velocityreviews.com/forums/t359670-wmi-help.html import wmi Not in the stdlib, but available here: http://pypi.python.org/pypi/WMI/1.3 and requires in turn pywin32: http://pypi.python.org/pypi/pywin32/210 c = wm

python way to automate IE8's File Download dialog

2009-06-04 Thread monogeo
Hello, I am able to use PAMIE 2.0 to automate IE7's File Download dialog, but the same approach/code fails on IE8. You can see the details and code at http://tech.groups.yahoo.com/group/Pamie_UsersGroup/message/675 Please help if you are able to automate IE8's File Download dialog (with three but

"where" in python

2009-06-04 Thread Chris
I am a newby in Python and I'm first looking for equivalent to things I already manage: IDL. For example, I want to plot a sub-set of points, selected from a bigger set by applying some filter. In my example, I want to select only the values > 0. I succeed to write 5 different ways to do this, whic

  1   2   >