| Store | Cart

Re: [Python-Dev] super() does not work during class initialization

From: Nick Coghlan <ncog...@gmail.com>
Wed, 25 Mar 2015 22:32:03 +1000
On 24 March 2015 at 08:22, Greg Ewing <greg...@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   |   ncog...@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-Dev mailing list
Pyth...@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: https://mail.python.org/mailman/options/python-dev/python-dev-ml%40activestate.com

Recent Messages in this Thread
Martin Teichmann Mar 20, 2015 02:03 pm
Nick Coghlan Mar 21, 2015 12:11 pm
Martin Teichmann Mar 23, 2015 09:38 am
Greg Ewing Mar 23, 2015 10:22 pm
Nick Coghlan Mar 25, 2015 12:32 pm
Martin Teichmann Mar 25, 2015 02:29 pm
Messages in this thread