import overwrites __name__

Marco marco.mandl at gmx.at
Fri May 8 17:37:25 EDT 2009


Stephen Hansen wrote:

>>
>>  So what leads to the behavior that the .pyc is not created?
>>
> 
> PYC's are only generated on import, they're never made for the main
> script.
> 
> I personally like to keep my 'main script' very small. Largely just
> something which imports other modules and sends them along on their
> business.

Thanks Stephen,

I just learned that. But still I don't know why there is a different 
(correct) behavior when the main module is compiled.

As a work-around I put this on top of my main script:

import py_compile
py_compile.compile(__file__)

Still I appreciate if someone could explain me why.

br
Marco 





More information about the Python-list mailing list