from __future__ import absolute_import issue

LittleGrasshopper seattlehanks at
Thu May 21 01:30:18 CEST 2009

On May 20, 4:18 pm, LittleGrasshopper <seattleha... at> wrote:
> New to the group, this is my first post...
> It appears that either absolute imports (or my brain) aren't working.
> Given a module which is in the same directory as
> #File
> from __future__ import absolute_import
> import string
> print string # Module imported is in current directory, not
> standard library module
> It imports the string module in the current directory, not the stirng
> module defined in the standard library.
> I've also noticed (by printing sys.path) that the current directory
> seems to always be included as the first element in sys.path, even
> when absolute_import is used.
> Any help appreciated.

I think I figured this out. Just because a module is in a directory
with an module it doesn't put it inside the package. For a
module to be in a package, it must be imported through the package. If
it is just executed as a top-level script, or imported (but not
through the package) the module is for all effects not in a package.

More information about the Python-list mailing list