Re: from __future__ import absolute_import ?
- From: Peter Otten <__peter__@xxxxxx>
- Date: Fri, 02 Feb 2007 18:22:44 +0100
Ron Adam wrote:
from __future__ import absolute_import
Is there a way to check if this is working? I get the same results with
or without it.
Python 2.5 (r25:51908, Sep 19 2006, 09:52:17)
[MSC v.1310 32 bit (Intel)] on win 32
If there are two modules 'foo', one at the toplevel and the other inside a
package 'bar',
from __future__ import absolute_import
import foo
will import the toplevel module whereas
import foo
will import bar.foo. A messy demonstration:
$ ls bar
absolute.py foo.py __init__.py relative.py
$ cat bar/absolute.py
from __future__ import absolute_import
import foo
$ cat bar/relative.py
import foo
$ cat foo.py
print "toplevel"
$ cat bar/foo.py
print "in bar"
$ python2.5 -c 'import bar.absolute'
toplevel
$ python2.5 -c 'import bar.relative'
in bar
Another example is here:
http://mail.python.org/pipermail/python-list/2007-January/422889.html
Peter
.
- Follow-Ups:
- Re: from __future__ import absolute_import ?
- From: Ron Adam
- Re: from __future__ import absolute_import ?
- From: Peter Otten
- Re: from __future__ import absolute_import ?
- References:
- from __future__ import absolute_import ?
- From: Ron Adam
- from __future__ import absolute_import ?
- Prev by Date: Re: asyncore DoS vulnerability
- Next by Date: Re: from __future__ import absolute_import ?
- Previous by thread: from __future__ import absolute_import ?
- Next by thread: Re: from __future__ import absolute_import ?
- Index(es):
Relevant Pages
|