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

Nick Coghlan ncoghlan at gmail.com
Sun Feb 1 08:33:58 CET 2009


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)

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.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------


More information about the Python-checkins mailing list