"Raymond Hettinger" <[EMAIL PROTECTED]> wrote: > Proto-PEP: Information Attributes (First Draft) > > Proposal: > > Testing hasattr() is a broadly applicable and flexible technique that works > well > whenever the presence of a method has an unambiguous interpretation > (i.e. __hash__ for hashability, __iter__ for iterability, __len__ for sized > containers); however, there are other methods with ambiguous interpretations > that could be resolved by adding an information attribute.
To me, this seems more like traits/roles than ABCs. Though I haven't weighed in on either of them, generally I'm with Raymond and others in the whole "ABCs seem like overkill" perspective. As such, I'm -1 on ABCs, but +1 on the general idea of traits/roles - of which I would consider this PEP to be one. My concern with Information Attributes is similar to my concern about ABCs; in order to state the information available from these information attributes, they need to be part of the class or instance. On built-in types, users would not be able to add things to classes or instances, as is the case with the numpy folks wanting to add 'ring' to integers. While I've not seen a PEP for offering live traits/roles addition or removal, I suspect that it would involve weak key dictionaries adding traits to classes, and only allow hashable instances for single-object trait additions (depending on the kinds of traits/roles, it could probably be implemented as a dictionary of weak key sets). I would be +1 in this case, as it would offer most of the benefits of ABCs*, with none of the pre-implementation drawbacks. - Josiah * Related to ABCs is the __issubclass__ and __isinstance__ stuff that allows for proxy objects directly. Traits/roles could be massaged to do similar things, but using __is...__ directly seems like it would perform this operation better. I'm not a real big _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
