Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #2265 > unrolled thread
| Started by | Michael Parker <michael.g.parker@gmail.com> |
|---|---|
| First post | 2011-03-30 19:26 -0700 |
| Last post | 2011-04-13 16:10 -0700 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
Forcing absolute package imports in 2.7? Michael Parker <michael.g.parker@gmail.com> - 2011-03-30 19:26 -0700
Re: Forcing absolute package imports in 2.7? aahz@pythoncraft.com (Aahz) - 2011-04-13 16:10 -0700
| From | Michael Parker <michael.g.parker@gmail.com> |
|---|---|
| Date | 2011-03-30 19:26 -0700 |
| Subject | Forcing absolute package imports in 2.7? |
| Message-ID | <mailman.23.1301538403.2990.python-list@python.org> |
Hi all, I'm reading Learning Python 4th Edition by Lutz. In the section on relative package imports, he says: "In Python 3.0, the `import modname` statement is always absolute, skipping the containing package’s directory. In 2.6, this statement form still performs relative imports today (i.e., the package’s directory is searched first), but these will become absolute in Python 2.7, too.` But in my own testing I'm not seeing this behavior. Was it not included in 2.7 for fear of breaking too many programs? Thanks! - Mike
[toc] | [next] | [standalone]
| From | aahz@pythoncraft.com (Aahz) |
|---|---|
| Date | 2011-04-13 16:10 -0700 |
| Message-ID | <io5age$l2s$1@panix5.panix.com> |
| In reply to | #2265 |
In article <mailman.23.1301538403.2990.python-list@python.org>, Michael Parker <michael.g.parker@gmail.com> wrote: > >I'm reading Learning Python 4th Edition by Lutz. In the section on >relative package imports, he says: "In Python 3.0, the `import >modname` statement is always absolute, skipping the containing >package=92s directory. In 2.6, this statement form still performs >relative imports today (i.e., the package=92s directory is searched >first), but these will become absolute in Python 2.7, too.` > >But in my own testing I'm not seeing this behavior. Was it not >included in 2.7 for fear of breaking too many programs? from __future__ import absolute_import -- Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/ "At Resolver we've found it useful to short-circuit any doubt and just refer to comments in code as 'lies'. :-)" --Michael Foord paraphrases Christian Muirhead on python-dev, 2009-03-22
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web