> On Thu, 6 Feb 2003, Guido van Rossum wrote: > > Can you suggest a concrete syntax to do this? Maybe setting __slots__ > > to a dictionary mapping names to type specifiers would do it -- and it > > would even be backwards compatible: currently, if __slots__ is a dict, > > its keys are used as slot names and its values are ignored, by virtue > > of the way the type constructor iterates over __slots__. > > I already use __slots__ assigned to dictionaries where the values are not > ignored. They are interpreted by a metaclass to apply type conversion > operators and type/value enforcement predicates to slots. I hope that > future versions of Python will not tread on this feature. (Though I'd > happily trade in this feature in exchange for having __slots__ be immutable) Hm... Given this feedback, it sounds like the only way to implement Christian's suggestion in a backwards-compatible way would be to use a different __xxx__ name, e.g. __fields__. I also like the suggestion of allowing control over the order as well. --Guido van Rossum (home page: http://www.python.org/~guido/)
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