[Python-Dev] PEP: Ordered Class Definition Namespace
vgr255 at live.ca
Tue Jun 7 14:57:16 EDT 2016
> From: Eric Snow
> Sent: Tuesday, June 07, 2016 2:52 PM
> To: Émanuel Barry
> Cc: Python-Dev
> Subject: Re: [Python-Dev] PEP: Ordered Class Definition Namespace
> "dunder" names (not just methods) will not be present in
> __definition_order__. I'll add an explanation to the PEP. The gist
> of it is that they are reserved for use by the interpreter and will
> always clutter up __definition_order__. Since needing dunder names
> included in __definition_order__ would be rather exceptional, and
> there are other options available, leaving them out by default is a
> matter of practicality.
Good point. I'll assume that if we need that we'll do something in the metaclass.
> What is the value of type.definition_order()? If you need a mutable
> copy then pass __definition_order__ to list().
I think I explained it backwards. I meant to have a method on ``type`` (which metaclasses can override at will) which will set what is passed to the resulting __definition_order__ attribute. But it might not be needed, as we can probably sneak that inside the namespace in the metaclass' __new__.
> > Additionally
> > I'm not sure if setting the attribute to None is a good idea; I'd have it as
> > an empty tuple. Then again I tend to overthink a lot.
> None indicates that there is no order. An empty tuple indicates that
> there were no attributes.
More information about the Python-Dev