[Python-Dev] PEP 420 - dynamic path computation is missing rationale

Eric V. Smith eric at trueblade.com
Tue May 22 02:32:10 CEST 2012


On 5/21/2012 2:08 PM, PJ Eby wrote:
> On Mon, May 21, 2012 at 9:55 AM, Guido van Rossum <guido at python.org
> <mailto:guido at python.org>> wrote:
> 
>     Ah, I see. But I disagree that this is a reasonable constraint on
>     sys.path. The magic __path__ object of a toplevel namespace module
>     should know it is a toplevel module, and explicitly refetch sys.path
>     rather than just keeping around a copy.
> 
> 
> That's fine by me - the class could actually be defined to take a module
> name and attribute (e.g. 'sys', 'path' or 'foo', '__path__'), and then
> there'd be no need to special case anything: it would behave exactly the
> same way for subpackages and top-level packages.

Any reason to make this the string "sys" or "foo", and not the module
itself? Can the module be replaced in sys.modules? Mostly I'm just curious.

But regardless, I'm okay with keeping these both as strings and looking
it up in sys.modules and then by attribute.

Eric.


More information about the Python-Dev mailing list