PEP 328, absolute/relative import
bokr at oz.net
Thu Aug 11 20:36:19 CEST 2005
On Thu, 11 Aug 2005 08:25:26 -0400, Peter Hansen <peter at engcorp.com> wrote:
>Ben Finney wrote:
>> Aahz <aahz at pythoncraft.com> wrote:
>>>Ben Finney <bignose+hates-spam at benfinney.id.au> wrote:
>>>>So, under PEP 328 rules, the original poster's current-directory
>>>>module could only be imported (a) if the current directory was in
>>>>sys.path, or (b) if the code specified a relative import. The
>>>>accidental shadowing of the stdlib module could not happen.
>>>Normally the current directory *is* on sys.path, and the first
>> So, modules in the current directory will continue to be imported as
>> before, because they *are* absolute imports by PEP328 definitions.
>Correct. We'll still be seeing newbies (and the odd experienced
>Pythonista) mistakenly shadowing standard library modules with
>name-colliding local ones well after PEP 328 is fully implemented.
>Gotta keep people on their feet! :-)
Will/should an __init__.py in the current directory be required,
to control what happens (and lessen the probability of accidental
collision from a random working directory)?
More information about the Python-list