[Import-SIG] Where to discuss PEP 382 vs. PEP 402 (namespace packages)?
ncoghlan at gmail.com
Mon Mar 12 06:17:55 CET 2012
On Mon, Mar 12, 2012 at 3:07 PM, Barry Warsaw <barry at python.org> wrote:
> On Mar 12, 2012, at 12:28 PM, Nick Coghlan wrote:
>>Why is this a problem?
> % mkdir parent
> % mkdir parent/zope.pyp
> % touch parent/zope.pyp/__init__.py
> % PYTHONPATH=parent python3.2
> Python 3.2.3rc1 (default, Mar 9 2012, 23:02:43)
> [GCC 4.6.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import zope
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> ImportError: No module named zope
But that's the moral equivalent of using "yield from" and expecting
your code to still be importable under Python 3.2 instead of
triggering SyntaxError. This is a new-in-Python-3.3 feature, *of
course* it isn't going to work with Python 3.2.
If you have to support 3.2, then you have to write 3.2 compatible
code, *including* your package layouts. Ergo:
% mkdir parent
% mkdir parent/zope
% touch parent/zope/__init__.py
% PYTHONPATH=parent python3.2
Python 3.2.3rc1 (default, Mar 9 2012, 23:02:43)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import zope
And the legacy package layout will still work in Python 3.3.
This whole objection just doesn't make any sense to me - yes, the new
feature won't work in old versions of Python. Code that wants to
remain compatible with old versions of Python can't rely on the new
feature. How is this different from having to avoid using any other
new feature like "yield from"?
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Import-SIG