[Python-Dev] super() does not work during class initialization
Nick Coghlan
ncoghlan at gmail.com
Wed Mar 25 13:32:03 CET 2015
More information about the Python-Dev mailing list
Wed Mar 25 13:32:03 CET 2015
- Previous message (by thread): [Python-Dev] super() does not work during class initialization
- Next message (by thread): [Python-Dev] super() does not work during class initialization
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 24 March 2015 at 08:22, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote: > Martin Teichmann wrote: >> >> maybe >> we could just change the compiler to leave the order in which things are >> defined >> in a class in the class namespace, say as a member __order__? Then we >> could >> use plain-old dicts for the class namespace, and we would not slow down >> class >> creation (not that it matters much), as determining the order would happen >> at >> compile time. > > > I don't think the compiler can determine the order in > all cases. Consider: > > class Spam: > > if moon_is_full: > alpha = 1 > beta = 2 > else: > beta = 2 > alpha = 1 This is also expected to work in class namespaces: locals()["alpha"] = 1 The language reference suggests it isn't, there's an open tracker issue I filed some time ago to suggest clarifying it but haven't found the time to actually sit down and come up with readable wording: http://bugs.python.org/issue17960 Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message (by thread): [Python-Dev] super() does not work during class initialization
- Next message (by thread): [Python-Dev] super() does not work during class initialization
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list