Michael McLay wrote: > > I was suprised by a change to the order of evaluation of members in the new > object type. I haven't found an explanation for why the change was made. I > was comfortable with the way it worked. Is there an advantage to the change?. > > In the classic python model the interpreter looked in the instance dictionary > and if the name wasn't there it looked in the class dictionary. The > following illustrates this evaluation order. > ... > > With the new slots mechanism the order has been reversed. The class level > dictionary is searched and then the slots are evaluated. > > >>> class B(object): > __slots__ = ['a','b','c'] > > >>> b = B() > >>> b.a = 4 > >>> b.a > 4 > >>> B.a = 6 > >>> b.a > 6 > >>> b.a = 8 > Traceback (most recent call last): > File "<pyshell#61>", line 1, in ? > b.a = 8 > AttributeError: 'B' object attribute 'a' is read-only Could someone please first explain what these slots are used for in the first place :-? There must be some difference to standard class attributes... which is probably also the reason for the above behaviour (even though it does look like a bug to me). -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4