[Python-checkins] r69167 - in python/branches/py3k/Lib/importlib: NOTES _bootstrap.py test/frozen/test_loader.py

Brett Cannon brett at python.org
Sun Feb 1 11:28:36 CET 2009


On Sat, Jan 31, 2009 at 23:33, Nick Coghlan <ncoghlan at gmail.com> wrote:
> brett.cannon wrote:
>> +        elif '.' in module.__name__:
>> +            module.__package__ = module.__name__.rsplit('.', 1)[0]
>
> 1. When determining a package name, rpartition is your friend (see the
> relevant code in runpy.py)
>

I guess I could, but the semantics are the same. Although I see you
hard-coded using rpartition in PEP 366. =)

> 2. It's OK to set __package__ even in a top-level module (just set it to
> the empty string). That is why rpartition works so well for the application.

The PEP doesn't say that, although I guess your
``__name__.rpartition('.')[0]`` line makes that implicit. Could you
edit the PEP to mention that the empty string is okay?

-Brett


More information about the Python-checkins mailing list