On Mon, May 3, 2021 at 6:49 PM Stestagg <[email protected]> wrote:
> class A:
> Namespace B:
> C = 1
>
> A.__dict__ == {‘B.C’: 1, ‘B’: <namespace proxy>}
OK, that is a difference. I don't really understand why it's desirable,
but I see the difference.
I can make that happen with a metaclass that would allow:
class A(MagicNamespace):
class B:
C = 1
A.__dict__ == {'B.C': 1, 'B': <class 'module.B'>}
So that wouldn't be identical in the repr(), but is there something else
important here?
In general, I find it anathema to add syntax for something that is easily
handled by existing inheritance mechanisms. If I want to, I can even make
every class defined within the body of a MagicNamespace magically become a
MagicNamespace too, if that's a thing someone wants.
Actually, I might not even need a metaclass, a MagicNamespace.__new__()
method might be adequate. I haven't fully thought it out.
--
The dead increasingly dominate and strangle both the living and the
not-yet born. Vampiric capital and undead corporate persons abuse
the lives and control the thoughts of homo faber. Ideas, once born,
become abortifacients against new conceptions.
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/5T7HQGZSLX7Z6W2LSDB4JH2N55FBIZVX/
Code of Conduct: http://python.org/psf/codeofconduct/