On 5/21/2012 2:08 PM, PJ Eby wrote:
On Mon, May 21, 2012 at 9:55 AM, Guido van Rossum <guido@python.org <mailto:guido@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.