On Wed, Sep 6, 2017 at 1:52 AM, Nathaniel Smith <n...@pobox.com> wrote:
​[...]​


> import sys, types
> class _MyModuleType(types.ModuleType):
>     @property
>     def ...
>
>     @property
>     def ...
> sys.modules[__name__].__class__ = _MyModuleType
>
> It's definitely true though that they're not the most obvious lines of
> code :-)
>
>
​It would kind of be in line with the present behavior if you could simply
write something like this in the module:

class __class__(types.ModuleType):
​    @property
    def hello(self):
        return "hello"

    def __dir__(self):
        return ["hello"]



assuming it would be equivalent to setting __class__ afterwards.​

​--Koos​




-- 
+ Koos Zevenhoven + http://twitter.com/k7hoven +
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to