So yes... as I thought, SimpleNamespace does EVERYTHING described by the
proposal, just without needing more keywords:

>>> from types import SimpleNamespace
>>> class A(SimpleNamespace):
...     class B(SimpleNamespace):
...         foo = 'bar'
...
>>> A.B.foo
'bar'
>>> A.B
<class '__main__.A.B'>
>>> import sys
>>> vars(sys.modules[__name__])["A"]
<class '__main__.A'>
>>> class Example:
...     class foo(SimpleNamespace):
...         def bar(self):
...             print("hello")
...
>>> Example.foo.bar
<function Example.foo.bar at 0x7fa8408bb710>
>>> Example.foo.bar(None)
hello

I mean, yes if you want the repr to be `<namespace blah blah...>` this is
different.  But nothing functional is not already available this way.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/CXCBDCGS2ZQOGGWCM5B36GEO3WNQRCMW/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to