Message 404475 - Python tracker (original) (raw)

+1 on a proxy (with read-only attrs) for everything but name, file, and path (which can all be different than the spec). Ideally name and file would be read-only too but they'd have to be stored somewhere other than the spec (e.g. on the proxy or module object). path could be similarly proxied but would at the least have to be mutable.

The nice thing about such attrs is they wouldn't show up in the module's dict, assuming they are properties.

The only catch I see is where the module's code sets one of the attrs. Would the proxy (or import machinery) pick those up, or maybe for some of them emit a warning or fail?

We could also skip the proxy and add the properties to ModuleType directly, no?