Silke von Bargen wrote: > >> That still leaves the question of what to do with __file__ (for which >> even the solution in the PEP isn't particularly clean). Perhaps the >> thing to do there is to have __file__ always point to the source file >> and introduce a __file_cached__ that points to the bytecompiled file on >> disk (set to None if it doesn't exist, as may be the case for __main__ >> or due to writing of bytecode files being disabled). > And what if there isn't a source file, because I want to deploy the > byte-code only? > This is possible now, but would be impossible if there was this kind of > distinction.
For a bytecode only deployment, __file__ would point to where the source file *would* be if it was there while __file_cached__ would point to the precompiled byte code. Yes, this would be backwards incompatible for some uses of execfile in conjunction with __file__ but those should be much rarer than uses of __file__ to locate source code (which break with bytecode only deployment anyway) and to find colocated resource files (which only care about the path to the file and not the filename itself). Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia --------------------------------------------------------------- _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com