[Python-Dev] PEP 520: Preserving Class Attribute Definition Order (round 5) (original) (raw)
Eric Snow ericsnowcurrently at gmail.com
Fri Jun 24 21:28:34 EDT 2016
- Previous message (by thread): [Python-Dev] PEP 520: Preserving Class Attribute Definition Order (round 5)
- Next message (by thread): [Python-Dev] PEP 520: Preserving Class Attribute Definition Order (round 5)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, Jun 24, 2016 at 5:56 PM, Random832 <random832 at fastmail.com> wrote:
On Fri, Jun 24, 2016, at 17:52, Eric Snow wrote:
- 2 open questions (slots? drop read-only requirement?) It's worth noting that slots itself doesn't have a read-only requirement. It can be a tuple, any iterable of strings, or a single string (which means the object has a single slot).
That is somewhat orthogonal to this PEP.
Should dir() iterate in the order of definitionorder? What, if so, should be done about instance attributes, or attributes of multiple classes, or class attributes not present in definitionorder?
dir() relates to the object's namespace, not its class's definition namespace.
What happens to classes whose prepare doesn't return an OrderedDict?
The PEP already indicates that definition_order will be set to None.
Can definitionorder be reassigned at runtime?
That is the subject of one of the open questions. Guido has suggested that it should. I don't agree, but then I'm not Dutch. :)
Will it have the same constraints?
Given that folks generally shouldn't be setting it at runtime, there isn't much point to constraining it. :)
What if a metaclass defines getattribute in a way that specially handles definitionorder? If someone really wants to put a non-tuple there they will find a way. How hard do we want to think about ways to stop consenting adults from doing weird things with the definitionorder attribute?
The point of "consenting adults" is that the person breaking the rules is aware that they are doing so and that they are willing to accept the consequences. Also, note that the interpreter does not depend on definition_order in any way. As I say in the PEP, I'd rather definition_order remain read-only until there's a need.
-eric
- Previous message (by thread): [Python-Dev] PEP 520: Preserving Class Attribute Definition Order (round 5)
- Next message (by thread): [Python-Dev] PEP 520: Preserving Class Attribute Definition Order (round 5)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]