[Python-Dev] __file__

Nick Coghlan ncoghlan at gmail.com
Sat Feb 27 16:24:39 CET 2010


Brett Cannon wrote:
> On Fri, Feb 26, 2010 at 20:08, Glenn Linderman <v+python at g.nevcal.com
>     I'm not sure why what you did is different than what I did,
> 
> 
> -M uses runpy which is not directly equivalent to importing.

It's actually execution which is different from importing. Direct
execution doesn't care about filenames (it inspects the file itself to
figure out what it is), while importing cares a great deal.

Note that Glenn ran "foo.py" directly, while Brett did "import temp".

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------


More information about the Python-Dev mailing list