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

2009-10-12 Thread greg
Dave Angel wrote: The point you should get from that link is Don't do circular imports. Ever. No, I would say the lesson to be learned from this is don't use the same file as both a main script and an imported module. I would create another file called e.g. 'main.py' that simply contains

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

2009-10-12 Thread Dave Angel
greg wrote: div class=moz-text-flowed style=font-family: -moz-fixedDave Angel wrote: The point you should get from that link is Don't do circular imports. Ever. No, I would say the lesson to be learned from this is don't use the same file as both a main script and an imported module. I

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

2009-10-11 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

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

2009-10-11 Thread ryles
On Oct 10, 7:36 pm, Stef Mientki stef.mien...@gmail.com wrote: 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

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

2009-10-11 Thread Stef Mientki
thanks very much Stephen, This is the first time I become aware of the difference between script and module !! Starting with the wrong book Learning Python second edition, from Lutz and Ascher, based on Python 2.3 in combination with using Python only from a high level IDE (PyScripter),

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

2009-10-11 Thread Dave Angel
(please don't top-post. Put your reply *after* the message you're quoting.) Stef Mientki wrote: div class=moz-text-flowed style=font-family: -moz-fixedthanks very much Stephen, This is the first time I become aware of the difference between script and module !! Starting with the wrong book

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

2009-10-11 Thread Stephen Fairchild
ryles wrote: 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

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

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

2009-10-10 Thread Benjamin Peterson
Stef Mientki stef.mientki at 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: 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 stef.mien...@gmail.comwrote: 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