import in Python3.3

Rocky Bernstein rocky at gnu.org
Tue Mar 26 18:24:02 EDT 2013


On Tue, Mar 26, 2013 at 5:16 PM, Phil Connell <pconnell at gmail.com> wrote:

> On Tue, Mar 26, 2013 at 08:37:00AM -0700, rocky wrote:
> > And again, I get the impression that for the use case asked about, there
> isn't much ambiguity. If I am in mypackage.foo and I want to access
> mypackage.collections I should be able to say something like that without
> ambiguity or that much inference or directory searching. If
> mypackage.colletions is not found inside the same directory as
> mypackage.foo, often I DON'T WANT Python to helpfully go searching around
> other places for it which sys.path will do. Instead what I probably want is
> Python to give me an error.
> >
> > So again I come to import_relative,
> http://code.google.com/p/pyimport-relative/.  And again, I wish this
> package didn't have to exist.
>
> What's wrong with PEP 328 relative imports?
>

They've never worked for me. Some details are mentioned that in the link
above.

If it works for you, great, use it.


> In mypackage.foo, use
>
>     from . import collections
>
> to import mypackage.collections.
>
>
> This has been part of the language since ~2.5
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130326/ff6dfae3/attachment.html>


More information about the Python-list mailing list