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

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​

--



More information about the Python-Dev mailing list