A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2014-November/137269.html below:

best approach to enabling "metamodules"?

[Python-Dev] advice needed: best approach to enabling "metamodules"? [Python-Dev] advice needed: best approach to enabling "metamodules"?Mark Shannon mark at hotpy.org
Sat Nov 29 17:46:27 CET 2014
On 29/11/14 01:59, Nathaniel Smith wrote:
> Hi all,
>
[snip]
>
> Option 3: Make it legal to assign to the __dict__ attribute of a
> module object, so that we can write something like
>
>     new_module = MyModuleSubclass(...)
>     new_module.__dict__ = sys.modules[__name__].__dict__
>     sys.modules[__name__].__dict__ = {}     # ***
>     sys.modules[__name__] = new_module
>

Why does MyModuleClass need to sub-class types.ModuleType?
Modules have no special behaviour, apart from the inability to write
to their __dict__ attribute, which is the very thing you don't want.

If it quacks like a module...

Cheers,
Mark.
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4