Creating classes and objects more than once?

Carl Banks pavlovevidence at gmail.com
Fri Nov 28 10:30:49 EST 2008


On Nov 28, 3:15 am, Ben Finney <bignose+hates-s... at benfinney.id.au>
wrote:
> Carl Banks <pavlovevide... at gmail.com> writes:
> > I like to think that "import abc" always does the same thing
> > regardless of any seemingly unrelated state changes of my program,
> > especially since, as the OP pointed out, import is used as a means
> > to ensure singleness. Thus, if I were designing the language, I
> > would have sys.path[0] be the current working directory at program
> > start.
>
> This is resolved in the Python 2.x series by implementing PEP 328
> <URL:http://www.python.org/dev/peps/pep-0328/>, such that the search
> path for ‘import’ does *not* contain the current directory, and
> requiring relative-to-the-current-directory imports to be explicitly
> requested.

PEP 328 doesn't say anything about that.  Using Python 2.5, which PEP
328 claims implements this change, I see the same behavior that Victor
Kerkez sees.  My sys.path[0] is still the empty string, meaning that
Python does start its import search from the current directory.

Perhaps you are confusing "current directory" with "directory that the
current module file is in", which PEP 328 does address?

(It's ok, the PEP itself used "current directory" in this way.)


Carl Banks



More information about the Python-list mailing list