[Python-Dev] PEP 395: Module Aliasing (original) (raw)
Steven D'Aprano steve at pearwood.info
Fri Mar 4 18:04:20 CET 2011
- Previous message: [Python-Dev] PEP 395: Module Aliasing
- Next message: [Python-Dev] PEP 395: Module Aliasing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Nick Coghlan wrote:
Fixing direct execution inside packages ---------------------------------------
To fix this problem, it is proposed that an additional filesystem check be performed before proceeding with direct execution of a
PYSOURCE
orPYCOMPILED
file that has been named on the command line. This additional check would look for an_init_
file that is a peer to the specified file with a matching extension (either.py
,.pyc
or.pyo
, depending what was passed on the command line). If this check fails to find anything, direct execution proceeds as usual. If, however, it finds something, execution is handed over to a helper function in therunpy
module thatrunpy.runpath
also invokes in the same circumstances. That function will walk back up the directory hierarchy from the supplied path, looking for the first directory that doesn't contain an_init_
file. Once that directory is found, it will be set tosys.path[0]
,
I think you mean that sys.path[0] will be set to the directory path.
Should the current working directory continue to be included in the path when running a sub-package module?
-- Steven
- Previous message: [Python-Dev] PEP 395: Module Aliasing
- Next message: [Python-Dev] PEP 395: Module Aliasing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]