Dynamic package exploration
Sebastien Pierre
spierre at rational.com
Fri Jul 21 20:15:34 EDT 2000
More information about the Python-list mailing list
Fri Jul 21 20:15:34 EDT 2000
- Previous message (by thread): Dynamic package exploration
- Next message (by thread): Dynamic package exploration
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Thomas Wouters wrote: > > On Fri, Jul 21, 2000 at 10:24:58PM +0000, Sebastien Pierre wrote: > > > I cannot reference any Python object using an absolute name... > > It's not an 'absolute name'. the 'os.name' isn't like a full path to a > filename. It merely references the attribute 'name' of object 'os'. > > > Example : > > >>print os.name > > fails.... > > But if I do > > >>import os > > >>print os.name > > It works - so I guess you have to "import" first before being able to > > reference anything. > > If they are modules, yes. If you do 'os.name' without importing os, Python > can't know which 'os' you are talking about ! After all, 'os' isn't a magic > name, it just happens to be the name of an often used module. Thanks for the explanation ! BTW, what happens if I do "import os" and then I do a "os=Thing()" and I do "print os.name", assuming that my Thing instance has a name="Hello" property ? I guess it will print "Hello" ....but what is the scope of name resolution, something like block->function->class->module ? Cheers, Seb. -- Sebastien Pierre.- spierre at rational.com \ R a t i o n a l software | XML \ If you like classical music, . Rational Unified Process | technology \ feel free to visit . Vancouver, B.C, -Canada | intern \ <www.costes.org>
- Previous message (by thread): Dynamic package exploration
- Next message (by thread): Dynamic package exploration
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list