Re: generator expression works in shell, NameError in script

2009-06-17 Thread Emile van Sebille
On 6/17/2009 3:41 PM Jason Tackaberry said... How about: enumerate([''] + titles) or perhaps, depending on usage... list(enumerate(titles)) Emile -- http://mail.python.org/mailman/listinfo/python-list

Re: generator expression works in shell, NameError in script

2009-06-17 Thread Jon Clements
On Jun 17, 11:19 pm, ssc wrote: > Hello, > > I am trying to generate this list of tuples: > [(0, ''), (1, 'Dr'), (2, 'Miss'), (3, 'Mr'), (4, 'Mrs'), (5, 'Ms')] > > My code works fine in the Python shell: > > >>> titles = ['Dr', 'Miss', 'Mr', 'Mrs', 'Ms',] > >>> title_choices = [(0, '')] + list((ti

Re: persistent composites

2009-06-17 Thread Rhodri James
On Wed, 17 Jun 2009 16:06:22 +0100, Aaron Brady wrote: On Jun 16, 10:09 am, Mike Kazantsev wrote: On Tue, 16 Jun 2009 06:57:13 -0700 (PDT) Aaron Brady wrote: > Making the charitable interpretation that this was the extent of c-l- > py's support and enthusiasm for my idea, I will now go in

Re: Pythonic way to overwrite a file

2009-06-17 Thread Rhodri James
Top-posting, tsk, tsk. On Wed, 17 Jun 2009 19:26:07 +0100, Cameron Pulsford wrote: Essentially it just cleans up a source file of erroneous spaces and tabs and can also convert tabs to spaces so loading the whole file into memory is possibly an option. I am making this utility for persona

Re: first full alpha release of PyLab_Works v0.3

2009-06-17 Thread Stef Mientki
program didn't start because .dll is missing (sorry I don't have the name)... I don't know if that is just an issue with the installer with vista or not (missing msv something 71. dll) You probably mean the microsoft visual C++ runtime (msvcr71.dll), windows vista has a brand new way (v

Re: generator expression works in shell, NameError in script

2009-06-17 Thread ssc
Wow! Didn't expect that kind of instant support. Thank you very much, I'll give both zip and enumerate a try. The code I've shown is actually copied pretty straight from a Django form class, but I didn't want to mention that as not to dilute the conversation. Don't think it matters, anyway. This i

Re: generator expression works in shell, NameError in script

2009-06-17 Thread Chris Rebert
On Wed, Jun 17, 2009 at 3:54 PM, ssc wrote: > Wow! Didn't expect that kind of instant support. Thank you very much, > I'll give both zip and enumerate a try. > > The code I've shown is actually copied pretty straight from a Django > form class, but I didn't want to mention that as not to dilute the

Re: generator expression works in shell, NameError in script

2009-06-17 Thread Emile van Sebille
On 6/17/2009 3:54 PM ssc said... Wow! Didn't expect that kind of instant support. Thank you very much, I'll give both zip and enumerate a try. The code I've shown is actually copied pretty straight from a Django form class, but I didn't want to mention that as not to dilute the conversation. Don

Re: TypeError: int argument required

2009-06-17 Thread Rhodri James
On Wed, 17 Jun 2009 12:07:15 +0100, Lawrence D'Oliveiro wrote: [snip example code] You haven't managed to get rid of the backslashes. [snip other example code] Now you've lost track of the original point of the discussion, which is about using alternate quotes to avoid backslashes. Ah,

Re: generator expression works in shell, NameError in script

2009-06-17 Thread Steven Samuel Cole
Both zip and enumerate do the trick. Thanks for the pointers, that's 2 more built-ins under my belt :-) Still don't really understand why my initial code didn't work, though... Thanks everyone! :-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Create 3D Surface / Contour (with vpython?)

2009-06-17 Thread norseman
Philip Gröger wrote: Hi! How can I create a 3D surface (or something like the picture on the FAQ page http://www.vpython.org/contents/FAQ.html ) with python [or vpython]. Didnt find anything in the Documentation under "graph" Basically like a contourf diagram in 3D (http://www.techsoft.de/germ

Re: python tutorial

2009-06-17 Thread steve
>"Carl Banks" wrote in message >news:2f6271b1-5ffa-4cec-81f8->>0276ad647...@p5g2000pre.googlegroups.com... >On Jun 15, 7:56 pm, "steve" wrote: >> I was just looking at the python tutorial, and I noticed these lines: >> >> http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-...

Re: python tutorial

2009-06-17 Thread steve
"Steven D'Aprano" wrote in message news:pan.2009.06.16.04.29...@remove.this.cybersource.com.au... > On Mon, 15 Jun 2009 20:58:47 -0700, Carl Banks wrote: > >> On Jun 15, 7:56 pm, "steve" wrote: >>> I was just looking at the python tutorial, and I noticed these lines: >>> >>> http://docs.python.

Re: Exotic Logics

2009-06-17 Thread Steven D'Aprano
On Wed, 17 Jun 2009 16:37:04 +, Lie Ryan wrote: >> Imagine for a moment that there are no boolean values. There are no >> numbers. They were never invented. There are no classes. >> There are no objects. >> There are only functions. >> >> Could you define functions that act like boolean valu

Re: python tutorial

2009-06-17 Thread Robert Kern
On 2009-06-17 19:36, steve wrote: "Carl Banks" wrote in message news:2f6271b1-5ffa-4cec-81f8->>0276ad647...@p5g2000pre.googlegroups.com... On Jun 15, 7:56 pm, "steve" wrote: I was just looking at the python tutorial, and I noticed these lines: http://docs.python.org/tutorial/inputoutput.html#

Re: python tutorial

2009-06-17 Thread Steven D'Aprano
On Thu, 18 Jun 2009 10:36:01 +1000, steve wrote: > 1) Windows does not make a distinction between text and binary files. Of course it does. Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more informatio

Re: Exceptions and Object Destruction (was: Problem with apsw and garbage collection)

2009-06-17 Thread Steven D'Aprano
On Wed, 17 Jun 2009 07:49:52 -0400, Charles Yeomans wrote: >> Even CPython doesn't rely completely on reference counting (it has a >> fallback gc for cyclic garbage). Python introduced the "with" >> statement to get away from the kludgy CPython programmer practice of >> opening files and relying

Re: Exceptions and Object Destruction (was: Problem with apsw and garbage collection)

2009-06-17 Thread Steven D'Aprano
On Wed, 17 Jun 2009 23:29:48 +1200, Lawrence D'Oliveiro wrote: > In message <7x7hzbv14a@ruckus.brouhaha.com>, wrote: > >> Lawrence D'Oliveiro writes: >> >>> > Reference counting is an implementation detail used by CPython but >>> > not [implementations built on runtimes designed for >>> > c

Re: walking a directory with very many files

2009-06-17 Thread Mike Kazantsev
On Thu, 18 Jun 2009 10:33:49 +1200 Lawrence D'Oliveiro wrote: > In message <20090617214535.10866...@coercion>, Mike Kazantsev wrote: > > > On Wed, 17 Jun 2009 23:04:37 +1200 > > Lawrence D'Oliveiro wrote: > > > >> In message <20090617142431.2b25f...@malediction>, Mike Kazantsev wrote: > >> >

How can I enumerate (list) serial ports?

2009-06-17 Thread Jason
Hi, I'm developing an application to talk to a device over a serial port. I'm trying my hardest to keep it cross platform, so I was using pySerial for the serial communications. But I can't see a pythonic, cross-platform way to enumerate serial ports on a machine. Ideally I could show the user a

GUI(eclipse+pydev/SPE) freeze when doing python auto-completion under Linux

2009-06-17 Thread Wei, James
When I am editing python program with SPE, I found that SPE will freeze when it is doing auto-completion. The behavior is very strange that I can not edit the file again. If I switch to another file and then switch back, I can edit it again. So I switch to eclipse+pydev, but I found the same thing

Re: GUI(eclipse+pydev/SPE) freeze when doing python auto-completion under Linux

2009-06-17 Thread Wei, James
On Jun 18, 10:45 am, "Wei, James" wrote: > When I am editing python program with SPE, I found that SPE will > freeze when it is doing auto-completion. The behavior is very strange > that I can not edit the file again. If I switch to another file and > then switch back, I can edit it again. > > So

Re: GUI(eclipse+pydev/SPE) freeze when doing python auto-completion under Linux

2009-06-17 Thread Tyler Laing
Do you experience the same problem even on an empty program file or is it limited to just one file? -Tyler On Wed, Jun 17, 2009 at 7:47 PM, Wei, James wrote: > On Jun 18, 10:45 am, "Wei, James" wrote: > > When I am editing python program with SPE, I found that SPE will > > freeze when it is do

Re: Exceptions and Object Destruction (was: Problem with apsw and garbage collection)

2009-06-17 Thread Charles Yeomans
On Jun 17, 2009, at 9:43 PM, Steven D'Aprano wrote: On Wed, 17 Jun 2009 07:49:52 -0400, Charles Yeomans wrote: Even CPython doesn't rely completely on reference counting (it has a fallback gc for cyclic garbage). Python introduced the "with" statement to get away from the kludgy CPython prog

fastest native python database?

2009-06-17 Thread per
hi all, i'm looking for a native python package to run a very simple data base. i was originally using cpickle with dictionaries for my problem, but i was making dictionaries out of very large text files (around 1000MB in size) and pickling was simply too slow. i am not looking for fancy SQL oper

Re: GUI(eclipse+pydev/SPE) freeze when doing python auto-completion under Linux

2009-06-17 Thread Wei, Xiaohai
yes, the same problem even on an empty program. every file has the same problem. for example, if I new a file and input the following: import os os. after I input '.', it will pop up the window, and i can select the function of os module or continue input. but after that, no action can be taken fo

Re: What text editor is everyone using for Python

2009-06-17 Thread JussiJ
On May 31, 12:42 am, edexter wrote: On the Windows platform the Zeus editor has Python language support: http://www.zeusedit.com > I will sometimes use word pad but i perfer syntax > highlighting.. The syntax highlighter is fully configurable. > I would be after is to be able to define my

Re: Exceptions and Object Destruction (was: Problem with apsw and garbage collection)

2009-06-17 Thread Steven D'Aprano
On Wed, 17 Jun 2009 22:58:27 -0400, Charles Yeomans wrote: > On Jun 17, 2009, at 9:43 PM, Steven D'Aprano wrote: > >> On Wed, 17 Jun 2009 07:49:52 -0400, Charles Yeomans wrote: >> Even CPython doesn't rely completely on reference counting (it has a fallback gc for cyclic garbage). Pyth

Re: fastest native python database?

2009-06-17 Thread Emile van Sebille
On 6/17/2009 8:28 PM per said... hi all, i'm looking for a native python package to run a very simple data base. i was originally using cpickle with dictionaries for my problem, but i was making dictionaries out of very large text files (around 1000MB in size) and pickling was simply too slow.

Re: fastest native python database?

2009-06-17 Thread per
i would like to add to my previous post that if an option like SQLite with a python interface (pysqlite) would be orders of magnitude faster than naive python options, i'd prefer that. but if that's not the case, a pure python solution without dependencies on other things would be the best option.

Re: What text editor is everyone using for Python

2009-06-17 Thread JussiJ
On May 26, 3:35 am, LittleGrasshopper wrote: > With so many choices, I was wondering what editor is the one you > prefer when coding Python, The Zeus for Windows IDE is Python aware: http://www.zeusedit.com/python.html > and why. It does syntax highlighting, smart indenting, code folding e

Re: fastest native python database?

2009-06-17 Thread William Clifford
On Jun 17, 8:28 pm, per wrote: > hi all, > > i'm looking for a native python package to run a very simple data > base. i was originally using cpickle with dictionaries for my problem, > but i was making dictionaries out of very large text files (around > 1000MB in size) and pickling was simply too

Re: Reading and setting file permissions programmatically

2009-06-17 Thread Kushal Kumaran
On Thu, Jun 18, 2009 at 2:05 AM, Cameron Pulsford wrote: > Sorry to flood the list but my google fu isn't up to par today I guess. > Basically, is it possible to read the permissions on one file and then set > the permissions of another file to the ones we just read? os.dup2 seemed > like it would

Re: walking a directory with very many files

2009-06-17 Thread Ethan Furman
Lawrence D'Oliveiro wrote: In message <20090617214535.10866...@coercion>, Mike Kazantsev wrote: On Wed, 17 Jun 2009 23:04:37 +1200 Lawrence D'Oliveiro wrote: In message <20090617142431.2b25f...@malediction>, Mike Kazantsev wrote: On Wed, 17 Jun 2009 17:53:33 +1200 Lawrence D'Oliveiro w

Re: Regarding Python is scripting language or not

2009-06-17 Thread Asun Friere
On Jun 18, 5:03 am, Terry Reedy wrote: > That depends on what you mean by 'put into classes' (and 'everything'). > > If you mean 'be an instance of a class', which I think is the most > natural reading, then Python *is* object-oriented and, if I understand > what I have read correctly (so that in

Re: fastest native python database?

2009-06-17 Thread Pierre Bourdon
On Thu, Jun 18, 2009 at 05:28, per wrote: > hi all, Hi, > i'm looking for a native python package to run a very simple data > base. i was originally using cpickle with dictionaries for my problem, > but i was making dictionaries out of very large text files (around > 1000MB in size) and pickling w

Re: waling a directory with very many files

2009-06-17 Thread Asun Friere
On Jun 15, 6:35 am, Andre Engels wrote: > What kind of directories are those that just a list of files would > result in a "very large" object? I don't think I have ever seen > directories with more than a few thousand files... (a...@lucrezia:~/pit/lsa/act:5)$ ls -1 | wc -l 142607 There, you'

Re: python tutorial

2009-06-17 Thread steve
"Robert Kern" wrote in message news:mailman.1728.1245289092.8015.python-l...@python.org... > On 2009-06-17 19:36, steve wrote: >>> "Carl Banks" wrote in message >>> news:2f6271b1-5ffa-4cec-81f8->>0276ad647...@p5g2000pre.googlegroups.com... >>> On Jun 15, 7:56 pm, "steve" wrote: I was just

Re: python tutorial

2009-06-17 Thread steve
"Steven D'Aprano" wrote in message news:pan.2009.06.18.01.42...@remove.this.cybersource.com.au... > On Thu, 18 Jun 2009 10:36:01 +1000, steve wrote: > >> 1) Windows does not make a distinction between text and binary files. > > Of course it does. > > > Python 2.6.2 (r262:71605, Apr 14 2009, 22:40

Re: How can I enumerate (list) serial ports?

2009-06-17 Thread Tim Golden
Jason wrote: Hi, I'm developing an application to talk to a device over a serial port. I'm trying my hardest to keep it cross platform, so I was using pySerial for the serial communications. But I can't see a pythonic, cross-platform way to enumerate serial ports on a machine. As with many oth

Re: Regarding Python is scripting language or not

2009-06-17 Thread Aaron Brady
On Jun 17, 7:38 am, Jean-Michel Pichavant wrote: > abhishek goswami wrote: > > Hi, > > I have very basic question about Python that do we consider pyhton as > > script language. > > I searched in google but it becomes more confusion for me. After some > > analysis I came to know that Python suppor

<    1   2