Jeremy Hylton wrote: > > >>>>> "PP" == Paul Prescod <paulp@ActiveState.com> writes: > > PP> I would like to argue that "plain old C types" should act as if > PP> they have __dict__s for consistency with other types. It is > PP> sometimes useful to be able to annotate objects by adding > PP> attributes to them. But this only works with class instance > PP> objects, not instances of types. > > Every type should have an __dict__ of type dict? Then every dict > must have an __dict__, including the __dict__ of __dict__? What's wrong with that? Every object has a type, even type objects, and type types. It only becomes a problem if you try to recursively walk all the dictionaries in the system adding information to them. Otherwise they have null pointers that "act as if" they were empty dictionaries. > Once every object has an __dict__, every object will be mutable. Then > no object will be usable as a dict key and we can get rid of dict's > entirely. According to that argument, instances cannot be dictionary keys. That is simply not true. Objects do not implement their hash functions in terms of ALL of their attributes! -- Take a recipe. Leave a recipe. Python Cookbook! http://www.ActiveState.com/pythoncookbook
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