Closed ericvsmith closed 7 years ago
The PEP doesn't say that fields are initialized in order, but I'd like to do so, anyway.
+1 from me, this adds predictability.
Agreed, it's a Python principle that things should be done in the order one would expect. (E.g. a+b is not allowed to evaluate b before a.)
Also, does the self really have to have such an ugly name? (I'd say only if there's a field named self.)
I already have a note to myself to change the naming of "self": I'll pick a new name only if there's a conflict. And it's always possible that the class will have an attribute collision on my "private" name, although I can't get too excited about working around that.
The PEP doesn't say that fields are initialized in order, but I'd like to do so, anyway.
If a field has a default_factory, and has init=False, it is initialized out of order. For this code:
The generated code looks like:
I'll rework field initialization to make sure this is handled correctly. I think there are also likely other corner cases.