Re: code in a module is executed twice (cyclic import problems) ?

2009-10-10 Thread Hendrik van Rooyen
On Sunday, 11 October 2009 02:24:34 Stephen Hansen wrote: > It's really better all around for "modules" to be considered like > libraries, that live over There, and aren't normally executed. Then you > have scripts over Here which may just be tiny and import a module and call > that module's "main

Why ELIF?

2009-10-10 Thread metal
I wonder the reason for ELIF. it's not aligned with IF, make code ugly IMHO OR maybe better? if foo == bar: ... or foo == baz: ... or foo == bra: ... else: ... -- http://mail.python.org/mailman/listinfo/python-list

Re: The rap against "while True:" loops

2009-10-10 Thread Hendrik van Rooyen
On Saturday, 10 October 2009 22:15:21 kj wrote: > I'm coaching a group of biologists on basic Python scripting. One > of my charges mentioned that he had come across the advice never > to use loops beginning with "while True". Of course, that's one > way to start an infinite loop, but this seems

Re: except KeyError: print("this was not a key error?")

2009-10-10 Thread Michel Alexandre Salim
On Oct 10, 7:59 pm, gert wrote: > http://code.google.com/p/appwsgi/source/browse/appwsgi/wsgi/order.wsgi > > I screwed up some sql statement > > INSERT INTO orders (pid,uid,bid,time) VALUES (?,?,2,DATETIME('NOW'))", > (v['pid']),s.UID) > > bid does not exist anymore, but why does the KeyError exce

Re: The rap against "while True:" loops

2009-10-10 Thread Terry Reedy
kj wrote: I use "while True"-loops often, and intend to continue doing this "while True", Me too. Of course, in Python, 'while True' actually means 'while ^C not pressed and window not closed and process not killed:', whereas in old mainframe Fortran the equivalent might have meant 'while

Script to complete web form fields

2009-10-10 Thread Feyo
How can I use Python to complete web form fields automatically? My work web-based email time-out is like 15 seconds. Every time I need to access my calendar, address book, or email, I have to type in my username and password. I'm just tired of it. I found the ClientForm module and have been workin

Re: Concept of God in islam

2009-10-10 Thread John Ladasky
On Oct 10, 12:25 pm, omer azazi wrote: > Sorry for not sending anything related to this group but it might be > something new to you. [198 lines deleted] Reported to GMail admins for spam. -- http://mail.python.org/mailman/listinfo/python-list

Re: datetime.datetime. or datetime. ?

2009-10-10 Thread Carl Banks
On Oct 10, 2:26 am, niklasr wrote: > On Oct 8, 10:17 pm, Carl Banks wrote: > > > > > On Oct 8, 3:11 pm, niklasr wrote: > > > > On Oct 8, 5:25 pm, "Diez B. Roggisch" wrote: > > > > > NiklasRTZ schrieb: > > > > > > Hello, my basic question is which recommendation is after slight > > > > > restruc

Re: code in a module is executed twice (cyclic import problems) ?

2009-10-10 Thread Stephen Hansen
On Sat, Oct 10, 2009 at 4:36 PM, Stef Mientki wrote: > hello, > > I always thought code in a module was only executed once, > but doesn't seem to be true. > This is one of the reasons why that whole big mess of a ton separate scripts that all call each-other and are sometimes imported and sometim

What happened to python-list archives?

2009-10-10 Thread David W.
Hey there, I just noticed http://mail.python.org/pipermail/python-list/ is lacking archives prior to December 2005. Is something broken? I see Google search results from 2003, so it seems something has changed. David. -- http://mail.python.org/mailman/listinfo/python-list

Re: code in a module is executed twice (cyclic import problems) ?

2009-10-10 Thread Benjamin Peterson
Stef Mientki gmail.com> writes: > Why is the B.py executed twice ? Because it's executed once as a script and once as a module. -- http://mail.python.org/mailman/listinfo/python-list

Re: No module named os

2009-10-10 Thread Scott David Daniels
smi...@home.com wrote: 'import site' failed; use -v for traceback Traceback (most recent call last): File "./setup.py", line 3, in import sys, os, glob ImportError: No module named os I'm trying to build a small program and I get the above error. I have had this error popup in the past w

except KeyError: print("this was not a key error?")

2009-10-10 Thread gert
http://code.google.com/p/appwsgi/source/browse/appwsgi/wsgi/order.wsgi I screwed up some sql statement INSERT INTO orders (pid,uid,bid,time) VALUES (?,?,2,DATETIME('NOW'))", (v['pid']),s.UID) bid does not exist anymore, but why does the KeyError exception occur when only my sql statement is wron

Re: The rap against "while True:" loops

2009-10-10 Thread Peter Billam
On 2009-10-10, kj wrote: > I use "while True"-loops often, and intend to continue doing this > "while True", but I'm curious to know: how widespread is the > injunction against such loops? Has it reached the status of > "best practice"? This trend is ironic; I remember in the structured-programm

code in a module is executed twice (cyclic import problems) ?

2009-10-10 Thread Stef Mientki
hello, I always thought code in a module was only executed once, but doesn't seem to be true. I'm using Python 2.5. And this is the example: == A.py == My_List = [] == B.py == from A import * My_List.append ( 3 ) print 'B', My_List import C == C.py == from A import * from B import * print 'C

Re: No module named os

2009-10-10 Thread Benjamin Peterson
home.com> writes: > I'm trying to build a small program and I get the above error. > I have had this error popup in the past while trying to build other > programs. What can I do? You're python is apparently not finding the standard library. -- http://mail.python.org/mailman/listinfo/python

Re: organizing your scripts, with plenty of re-use

2009-10-10 Thread Ethan Furman
Gabriel Genellina wrote: En Sat, 10 Oct 2009 05:57:08 -0300, Steven D'Aprano escribió: On Fri, 09 Oct 2009 16:37:28 -0700, Buck wrote: Here's a scenario. A user does a cvs checkout into some arbitrary directory and sees this: project/ +-- python/ +-- animals.py +-- mammals/

Re: vim clientserver [was: best vi / emacs python features]

2009-10-10 Thread TerryP
On Oct 10, 6:13 pm, Chris Jones wrote: > Hmm.. On *nix systems, decent applications understand the $EDITOR > environment variable - don't know about gnome & friends, though. > I tend to write programs that understand EDITOR, BROWSER, etc; wish the rest of the world did. > So what does the inter

Re: No threading.start_new_thread(), useful addition?

2009-10-10 Thread Carl Banks
On Oct 9, 3:45 pm, Christian Heimes wrote: > Laszlo Nagy wrote: > > IMHO it is much cleaner to implement this as a decorator. Pro: > > transparent passing of positional and keyword arguments, keeps function > > documentation. > > You are entitled to your opinion but I STRONGLY recommend against yo

Re: Best way to handle changing list of class imports

2009-10-10 Thread Scott Grant
On Oct 10, 6:44 pm, Dave Angel wrote: > Scott Grant wrote: > > On Oct 10, 2:42 pm, "Diez B. Roggisch" wrote: > > >> Scott Grant schrieb: > > >>> Hi there, > > >>> I'd like to set up a framework in which I can add or remove new > >>> classes of a given expected subclass to my package, and have the

Re: Best way to handle changing list of class imports

2009-10-10 Thread Dave Angel
Scott Grant wrote: On Oct 10, 2:42 pm, "Diez B. Roggisch" wrote: Scott Grant schrieb: Hi there, I'd like to set up a framework in which I can add or remove new classes of a given expected subclass to my package, and have the system load that set at runtime and be able to use

Re: The rap against "while True:" loops

2009-10-10 Thread Mensanator
On Oct 10, 5:02�pm, kj wrote: > In <01ccc46d-5ea9-4dfe-ba22-699c6b859...@v36g2000yqv.googlegroups.com> > Mensanator writes: > > > > > > >On Oct 10, 3:15=EF=BF=BDpm, kj wrote: > >> I'm coaching a group of biologists on basic Python scripting. =EF=BF=BDOn= > >e > >> of my charges mentioned that h

Re: The rap against "while True:" loops

2009-10-10 Thread Björn Lindqvist
I have many times screwed up "while True"-loops. When I thought I had a safe exit condition which turned out to be never reached in some rare corner cases. Leading to weird bugs with hanging threads. I have seen colleges screw up in the same way too. Often it is possible to reformulate "while True"

Re: How to find number of line that is currently executing?

2009-10-10 Thread ryles
On Oct 9, 11:46 pm, "Dr. Phillip M. Feldman" wrote: > I would like to put a statement on line N of my program that prints the line > number that is currently executing. inspect.currentframe().f_lineno http://docs.python.org/library/inspect.html -- http://mail.python.org/mailman/listinfo/python-

Re: The rap against "while True:" loops

2009-10-10 Thread kj
In <01ccc46d-5ea9-4dfe-ba22-699c6b859...@v36g2000yqv.googlegroups.com> Mensanator writes: >On Oct 10, 3:15=EF=BF=BDpm, kj wrote: >> I'm coaching a group of biologists on basic Python scripting. =EF=BF=BDOn= >e >> of my charges mentioned that he had come across the advice never >> to use loops b

No module named os

2009-10-10 Thread smitty
'import site' failed; use -v for traceback Traceback (most recent call last): File "./setup.py", line 3, in import sys, os, glob ImportError: No module named os I'm trying to build a small program and I get the above error. I have had this error popup in the past while trying to build othe

Re: The rap against "while True:" loops

2009-10-10 Thread Mensanator
On Oct 10, 3:15�pm, kj wrote: > I'm coaching a group of biologists on basic Python scripting. �One > of my charges mentioned that he had come across the advice never > to use loops beginning with "while True". �Of course, that's one > way to start an infinite loop, but this seems hardly a sufficie

Re: The rap against "while True:" loops

2009-10-10 Thread Boris Arloff
I agree there is no rap against "while True"-loops.  As an example these are very useful especially when receiving continuous data over a queue, pipe socket, or over any other connection.  You set to block, receive data, then process data and finally loop around to wait for next data segment.  O

Re: The rap against "while True:" loops

2009-10-10 Thread Stephen Hansen
> > I use "while True"-loops often, and intend to continue doing this > "while True", but I'm curious to know: how widespread is the > injunction against such loops? The injunction is nonexistent (save perhaps in people coming from another language who insist that Python just /must/ have a "prope

The rap against "while True:" loops

2009-10-10 Thread kj
I'm coaching a group of biologists on basic Python scripting. One of my charges mentioned that he had come across the advice never to use loops beginning with "while True". Of course, that's one way to start an infinite loop, but this seems hardly a sufficient reason to avoid the construct alt

Re: rfc: a self-editing script

2009-10-10 Thread gb345
In <0059c2b1$0$26930$c3e8...@news.astraweb.com> Steven D'Aprano writes: >But if you absolutely have to write to the program file... No, don't have to, beyond the urge to satisfy a very idiosyncratic aesthetic imperative... >then append your >data to the end of the file (as a comment) and late

Re: Best way to handle changing list of class imports

2009-10-10 Thread Scott Grant
On Oct 10, 2:42 pm, "Diez B. Roggisch" wrote: > Scott Grant schrieb: > > > > > Hi there, > > > I'd like to set up a framework in which I can add or remove new > > classes of a given expected subclass to my package, and have the > > system load that set at runtime and be able to use them.  In essen

Re: Best way to handle changing list of class imports

2009-10-10 Thread Diez B. Roggisch
Scott Grant schrieb: Hi there, I'd like to set up a framework in which I can add or remove new classes of a given expected subclass to my package, and have the system load that set at runtime and be able to use them. In essence, if I have a class X, and subclasses A, B, and C that derive from X

Best way to handle changing list of class imports

2009-10-10 Thread Scott Grant
Hi there, I'd like to set up a framework in which I can add or remove new classes of a given expected subclass to my package, and have the system load that set at runtime and be able to use them. In essence, if I have a class X, and subclasses A, B, and C that derive from X, what's the most pytho

[OT] vim clientserver [was: best vi / emacs python features]

2009-10-10 Thread Chris Jones
On Thu, Oct 08, 2009 at 12:59:00AM EDT, TerryP wrote: > On Oct 8, 3:29 am, Chris Jones wrote: [..] > It's most valuable for sending data to an existing instance of vim, by > name. Both files and keystrokes can be sent fwiw. [..] > On top of that, I sometimes group instances of vim into 'server

Re: organizing your scripts, with plenty of re-use

2009-10-10 Thread Gabriel Genellina
En Sat, 10 Oct 2009 05:57:08 -0300, Steven D'Aprano escribió: On Fri, 09 Oct 2009 16:37:28 -0700, Buck wrote: Here's a scenario. A user does a cvs checkout into some arbitrary directory and sees this: project/ +-- python/ +-- animals.py +-- mammals/ +-- horse.py +-- o

Re: organizing your scripts, with plenty of re-use

2009-10-10 Thread Gabriel Genellina
En Sat, 10 Oct 2009 05:57:08 -0300, Steven D'Aprano escribió: On Fri, 09 Oct 2009 16:37:28 -0700, Buck wrote: Here's a scenario. A user does a cvs checkout into some arbitrary directory and sees this: project/ +-- python/ +-- animals.py +-- mammals/ +-- horse.py +-- o

Re: Syntax question

2009-10-10 Thread Helmut Jarausch
Benjamin Peterson wrote: Helmut Jarausch skynet.be> writes: As I said, it's 'make' in Python's source directory (SVN revision 75309 Last Changed Date: 2009-10-10) I can't reproduce your failure. What are the exact commands you are using? CFLAGS='-O3 -mtune=native -msse2 -pipe' CXXFLAGS=$C

Re: Persistent Distributed Objects

2009-10-10 Thread Simon Forman
On Fri, Oct 9, 2009 at 1:11 AM, John Haggerty wrote: > I am interested in seeing how it would be possible in python to have > persistent objects (basically be able to save objects midway through a > computation, etc) and do so across multiple computers. > > Something that would allow for memory, d

Re: Syntax question

2009-10-10 Thread Benjamin Peterson
Helmut Jarausch skynet.be> writes: > As I said, it's 'make' in Python's source directory > (SVN revision 75309 Last Changed Date: 2009-10-10) I can't reproduce your failure. What are the exact commands you are using? -- http://mail.python.org/mailman/listinfo/python-list

Re: Syntax question

2009-10-10 Thread Helmut Jarausch
Benjamin Peterson wrote: Helmut Jarausch skynet.be> writes: Hi, I'm trying to build the recent Python-3.2a (SVN). It fails in Lib/tokenize.py (line 87) How are you invoking it? As I said, it's 'make' in Python's source directory (SVN revision 75309 Last Changed Date: 2009-10-10) If it

Re: Syntax question

2009-10-10 Thread Benjamin Peterson
Helmut Jarausch skynet.be> writes: > > Hi, > > I'm trying to build the recent Python-3.2a (SVN). > It fails in > Lib/tokenize.py (line 87) How are you invoking it? -- http://mail.python.org/mailman/listinfo/python-list

Re: Nested Menus

2009-10-10 Thread Victor Subervi
in line responses... On Thu, Oct 8, 2009 at 5:58 PM, Dennis Lee Bieber wrote: > On Thu, 8 Oct 2009 10:38:02 -0500, Victor Subervi > declaimed the following in > gmane.comp.python.general: > >First suggestion... Get rid of the confusing dat[0] and dat[1] and > use names that make sense...

Re: Zip Question

2009-10-10 Thread Victor Subervi
Ah! Thanks :) V On Fri, Oct 9, 2009 at 1:10 PM, Stephen Hansen wrote: > > > On Fri, Oct 9, 2009 at 11:04 AM, Victor Subervi > wrote: > >> So, because the results in sstp were duplicates ( ['prescriptions', >> 'prescriptions'] ) it only returned one result in the dict(zip()) statement. >> Weird.

Re: Looking for Python Developers in Jakarta, Indonesia

2009-10-10 Thread marmo
On Sep 23, 3:11 pm, kugutsumen wrote: > Responsibilities: > > You will be part of a team responsible for implementing and supporting > a Google App Engine based application. > > Requirements: > > Professional: University bachelor's degree in computer science or > related discipline (web developmen

Syntax question

2009-10-10 Thread Helmut Jarausch
Hi, I'm trying to build the recent Python-3.2a (SVN). It fails in Lib/tokenize.py (line 87) 85 def group(*choices): return '(' + '|'.join(choices) + ')' 86 def any(*choices): return group(*choices) + '*' 87 def maybe(*choices): return group(*choices) + '?' with: TypeError: group() argument

Re: easy install

2009-10-10 Thread Ethan Furman
>Ethan Furman wrote: >> A puzzlement: >> >> I used easy_install the other day to get xlutils on my system. It >> automatically installed xlrd and xlwt as well. This is cool. What's >> not so cool are my tracebacks. E.g. >> >> Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit

Re: How to find number of line that is currently executing?

2009-10-10 Thread koranthala
On Oct 10, 8:54 am, Chris Rebert wrote: > On Fri, Oct 9, 2009 at 8:46 PM, Dr. Phillip M. Feldman > > wrote: > > > I would like to put a statement on line N of my program that prints the line > > number that is currently executing. This may sound fairly trivial, but I > > don't want to hard code t

Re: No threading.start_new_thread(), useful addition?

2009-10-10 Thread Laszlo Nagy
Christian Heimes wote: Laszlo Nagy wrote: IMHO it is much cleaner to implement this as a decorator. Pro: transparent passing of positional and keyword arguments, keeps function documentation. You are entitled to your opinion but I STRONGLY recommend against your decorator. You MUST NO

Re: Enormous Input and Output Test

2009-10-10 Thread Irmen de Jong
John Yeung wrote: P.S. I hope people realize that the concise, intuitive, readable answers we all tried in our first couple of (failed) attempts are much more Pythonic than the beasts that were created just for SPOJ. Well, it is not often that we need to micro optimize stuff (or how would you

New hire

2009-10-10 Thread Emeka
Hello All, I am new to python , and my aim is to use it to write sugar-based applications on XO(OLPC). I am not new to programming in general, I would want to know the best route to take in learning python. I have background in FP and Imperative languages. Regards, Emeka -- http://mail.python.or

ANN: yappi 0.1 beta : Yet Another Python Profiler

2009-10-10 Thread k3xji
Hi all, After implementing a game server on which 100k people playing games per-day, it turns out to be that continuous and efficient profiling is key to improve an long-running applications like these. With this idea in mind, I am motivated to write a profiler. I am not a Python expert or even cl

Re: rfc: a self-editing script

2009-10-10 Thread garabik-news-2005-05
Steven D'Aprano wrote: ... > But if you absolutely have to write to the program file, then append your > data to the end of the file (as a comment) and later read that, rather > than modifying the actual code in place. That is, you fetch the > LAST_VERSION by reading the last non-empty line in

Re: Persistent Distributed Objects

2009-10-10 Thread Laszlo Nagy
Sorry about being interpreted as being vague. You wasn't vague. I'm sorry! `et me try to narrow it down. program a creates objects b c d which each need to use 1 disk space 2 ram 3 processor time. I would like to create a checkpoint which would save the work of the object to be later used a

Re: datetime.datetime. or datetime. ?

2009-10-10 Thread niklasr
On Oct 8, 8:33 pm, "Gabriel Genellina" wrote: > En Thu, 08 Oct 2009 19:11:04 -0300, niklasr escribió: > > > On Oct 8, 5:25 pm, "Diez B. Roggisch" wrote: > >> NiklasRTZ schrieb: > >> > Hello, my basic question is which recommendation is after slight > >> > restructuring datetime.datetime to datet

Re: Persistent Distributed Objects

2009-10-10 Thread OdarR
On 10 oct, 05:39, "bouncy...@gmail.com" wrote: > Sorry about being interpreted as being vague. `et me try to narrow it down. > program a creates objects b c d which each need to use 1 disk space 2 ram 3 > processor time. I would like to create a heckpoint which would save the work > of the obje

Re: datetime.datetime. or datetime. ?

2009-10-10 Thread niklasr
On Oct 8, 10:17 pm, Carl Banks wrote: > On Oct 8, 3:11 pm, niklasr wrote: > > > > > On Oct 8, 5:25 pm, "Diez B. Roggisch" wrote: > > > > NiklasRTZ schrieb: > > > > > Hello, my basic question is which recommendation is after slight > > > > restructuring datetime.datetime to datetime > > > > Both

Re: datetime.datetime. or datetime. ?

2009-10-10 Thread niklasr
On Oct 8, 7:34 pm, "Diez B. Roggisch" wrote: > niklasr schrieb: > > > > > On Oct 8, 5:25 pm, "Diez B. Roggisch" wrote: > >> NiklasRTZ schrieb: > > >>> Hello, my basic question is which recommendation is after slight > >>> restructuring datetime.datetime to datetime > >>> Both works but only one s

Re: Persistent Distributed Objects

2009-10-10 Thread OdarR
On 10 oct, 05:39, "bouncy...@gmail.com" wrote: > Sorry about being interpreted as being vague. `et me try to narrow it down. > program a creates objects b c d which each need to use 1 disk space 2 ram 3 > processor time. I would like to create a heckpoint which would save the work > of the obje

Re: can i use the browser to show the result of python

2009-10-10 Thread Hacken
On Oct 5, 5:16 pm, catafest wrote: > On Sep 25, 12:41 pm, Hacken wrote: > > > I have write some python script > > > i want to use browser(IE or FF) to call it, an show the returns! > > > how to? > > Python script running under web browsers only like: >  python + website = django . u can say that

Re: organizing your scripts, with plenty of re-use

2009-10-10 Thread Steven D'Aprano
On Fri, 09 Oct 2009 16:37:28 -0700, Buck wrote: > Here's a scenario. A user does a cvs checkout into some arbitrary > directory and sees this: > > project/ > +-- python/ > +-- animals.py > +-- mammals/ > +-- horse.py > +-- otter.py > +-- reptiles/ > +-- gator.p

Re: Tree Structure

2009-10-10 Thread Shakeeb Alireza
> Is there any python class to display the drive and folder structure as > a tree(As you see in the windows explorer window)?? http://wiki.wxpython.org/TreeControls S -- http://mail.python.org/mailman/listinfo/python-list

Re: Python 2.5 execfile() works only once, why ?

2009-10-10 Thread Steven D'Aprano
On Fri, 09 Oct 2009 20:15:48 +0200, Stef Mientki wrote: [...] > The above code (with or without the stdout redirection), works perfect, > > ... the first time ... > but does (almost?) nothing (doesn't crash, try / except around > execfile), although the source file "self.Edit.Filename" has ch

Re: rfc: a self-editing script

2009-10-10 Thread Steven D'Aprano
On Fri, 09 Oct 2009 23:30:16 +, gb345 wrote: > The following fragment is from a tiny maintenance script that, among > other things, edits itself, by rewriting the line that ends with '### > REPLACE'. > > ## > > import re > i