I wrote: > Wouldn't it be just as future-proof to make __slots__ a list of bare > slot names or objects? One advantage is that slot names don't have to > be carried around externally to the objects. Moreover, using standard > attribute names like __name__ and __doc__ will make the solution more > future-proof. > > The default metaclass will handle __slots__ along these lines: > > for item in obj.__slots__: > if isinstance(item, StringTypes): > slot_name, slot_doc = item, None > else: > slot_name = item.__name__ > slot_doc = getattr(item, '__doc__', None) > > In that way, the default metaclass does not impose any restrictions on > what the slot objects are. > > Example usage: > > class MySlot(object): > def __init__(self, name, doc=None): > self.__name__ = name > self.__doc__ = doc > > class C(object): > __slots__ = ['slot1', > MySlot('slot2', 'this is the docstring')] I am still very interested in seeing this happen. I'm looking for a Python C API expert who would be kind enough to get me started with the necessary mods to the default Python metaclass. I already have a prototype of the pydoc improvements which go hand-in-hand with this change (http://sourceforge.net/tracker/index.php?func=detail&aid=936774&group_id=5470&atid=305470). -John -- http://giftfile.org/ :: giftfile project
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