Namespace Qualification Question

Aahz aahzpy at panix.com
Fri Mar 22 14:50:31 EST 2002


In article <3C9B7C2A.20708 at cpsc.ucalgary.ca__no_spam__>,
Craig McLean  <mcleanc at cpsc.ucalgary.ca__no_spam__> wrote:
>
>Is there a module assosciated with the file you started the interpreter 
>with, and if there is what is it's name?  For instance
>
> > python qux.py
>
>I would have thought that there would be a qux module, and that it's 
>name would be stored in the __name__ builtin.

Nope.  As you'll see if you look in many modules, __name__ ==
'__main__', so that makes it easy to test whether your script is being
run directly or imported as a module.  Don't know off-hand what the
module is.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"We should forget about small efficiencies, about 97% of the time.
Premature optimization is the root of all evil."  --Knuth



More information about the Python-list mailing list