BartlebyScrivener wrote:
> >> More accurately, it *does* import it twice, into two separate
> >> namespaces;
>
> If it's in two different namespaces, how can they have the same id
> number?
they're mixing up the terminology. each loaded module has exactly one
namespace, no matter how many times
"BartlebyScrivener" <[EMAIL PROTECTED]> writes:
> >> More accurately, it *does* import it twice, into two separate
> >> namespaces;
>
> If it's in two different namespaces, how can they have the same id
> number?
That "two different namespaces" might be a bit inaccurate.
There is only one objec
Thank you for the elucidation. I'm just getting into Classes, but I
wanted to get modules down first.
Much appreciated.
rick
--
http://mail.python.org/mailman/listinfo/python-list
Although 'namespace' may be a misnomer, module interfaces are 'exposed'
to the module that imports it - it's not imported a second time into
the new 'namespace'. The confusion comes about thinking that modules
and classes are related.
When a module is first imported, an instance is created for th
>> More accurately, it *does* import it twice, into two separate
>> namespaces;
If it's in two different namespaces, how can they have the same id
number?
rick
--
http://mail.python.org/mailman/listinfo/python-list
Actually, it does not "execute the code only the first time", more
accurately, it "initializes the code only the first time".
But you are correct, it exposes the os.* module into the current
namespace so you don't have to go to convoluted lengths to get to it.
--
http://mail.python.org/mailman/l
"alisonken1" <[EMAIL PROTECTED]> writes:
> Unless you override some of os.* functions in foo, you want to
> import os into foo and bar separately.
>
> Python does not reimport the module a second time (create a second
> instance of os)
More accurately, it *does* import it twice, into two separat
You're right!
When running bar.py, id(os) and id(foo.os) give the same number!
Cool. I'll go read about INSTANCES and pointers.
Thank you very much,
rick
--
http://mail.python.org/mailman/listinfo/python-list
Unless you override some of os.* functions in foo, you want to import
os into foo and bar separately.
Python does not reimport the module a second time (create a second
instance of os), it only creates a pointer to the first instance that's
loaded.
--
http://mail.python.org/mailman/listinfo/pyth
I know this must have been answered a hundred times, but I must be
searching on the wrong terminology.
Let's say I have a module foo.py that imports os.
I make another script called bar.py that imports foo.py and now I want
to use, say, os.walk in bar.py.
Which is faster or more correct or whate
10 matches
Mail list logo