[Tutor] Cross-Module Interaction
Walter Prins
wprins at gmail.com
Sat Feb 26 12:11:29 CET 2011
On 26 February 2011 11:06, Corey Richardson <kb1pkl at aim.com> wrote:
> I ran them like this:
> python use1.py
> python use2.py
> python plib.py
>
> Each file got its own instance of the interpreter.
>
Yes, but not because instances are intrinsically linked to seperate python
modules, which is what it sounds like you're saying. In the above case you
*explicitly* started the 3 python instances seperately yourself from the
command line, giving each instance a file to run, which is why you got 3
seperate instances. It's nothing to do with the fact that you have 3 files
as such. (You'd have had 3 instances even if you ran the same file 3
times.) If you e.g. ran "use1.py" which then imported or ran use2.py and
use3.py they'd all have used the same instance. Similarly, if you'd opened
all 3 files in IDLE, and ran them with F5 in turn, they'd all have run in
the *same* interpreter instance. Perhaps you do understand and you've
expressed yourself poorly or I've just miinterpreted what you meant, I just
wanted to make sure you don't think that seperate files (modules) will by
some magic always have their own instances (which is not the case in
general.)
Walter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110226/70fb4b91/attachment.html>
More information about the Tutor
mailing list