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/2017-September/149244.html below:

[Python-Dev] PEP 549: Instance Properties (aka: module properties)

[Python-Dev] PEP 549: Instance Properties (aka: module properties) [Python-Dev] PEP 549: Instance Properties (aka: module properties)Koos Zevenhoven k7hoven at gmail.com
Wed Sep 6 17:19:58 EDT 2017
On Wed, Sep 6, 2017 at 1:52 AM, Nathaniel Smith <njs at 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 +
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20170907/88d4688b/attachment.html>
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