En Wed, 19 Dec 2007 07:02:00 -0300, Chris <[EMAIL PROTECTED]> escribió:
> #fp.py
> import cli
>
> #cli.py
> import os
>
> #config.py
> import cli
> print cli.os.environ['HOME']
>
> if you wish to use the os module loaded by the cli module
En Wed, 19 Dec 2007 09:42:31 -0300, Donn Ingle <[EMAIL PRO
> You guess. When fisrt imported, the module's source is executed, a
> module object is created and stored in sys.modules, and the needed names
> are inserted into the importing module's namespace. Next times the
> module is "served" directly from sys.modules.
Peachy, thanks.
\d
--
http://mail.
Donn Ingle a écrit :
>> would be a VeryBadThing(tm).
> :)
>
>> Having explicits imports in each module is good wrt/ readability.
> Okay, I can accept that. I worry that it's opening the module file over and
> over again
Hopefully not ! "import" is not "include".
> - or does it open it once an
Chris wrote:
> print cli.os.environ['HOME']
I was really confused by your reply until I saw the cli.os part. Okay, I see
what you mean.
\d
--
http://mail.python.org/mailman/listinfo/python-list
> would be a VeryBadThing(tm).
:)
> Having explicits imports in each module is good wrt/ readability.
Okay, I can accept that. I worry that it's opening the module file over and
over again - or does it open it once and kind of re-point to it when it
hits a second import of the same thing?
> pac
On Dec 19, 9:24 am, Donn Ingle <[EMAIL PROTECTED]> wrote:
> So, I guess I am confused about the 'scope' of what gets imported where. I
> am thinking that if one module (py file) does *import os* something and
> *then* imports another module - the second module should have access to os
> too?
> I i
Donn Ingle a écrit :
> Hi, I'm sure this is a FAQ, but I have just not found clarity on the
> web/docs.
>
> (using monospaced type to show the tree)
> trunk:$ tree
> .
> fp
> |-- fontypython
> | |-- __init__.py
> | |-- cli.py
> | |-- config.py
>
> (I start it all with ./fp)
>
> fp says:
>