On Apr 27, 2007, at 10:40 AM, Bill Janssen wrote: > Jim Jewett wrote: >> On 4/27/07, Barry Warsaw <[EMAIL PROTECTED]> wrote: >> >>> - - Attributes. Interfaces allow you to make assertions about >>> attributes, not just methods, while ABCs necessarily cover only >>> methods. >> >> Why can't they have data attributes as well? > > I agree with Jim. It seems to me that documenting standard attributes > of a type is one thing that ABC's should be able to do. Perhaps a > "@abstractattribute" decorator of some sort? Perhaps a class > decorator > "@attributes(name1, name2, ...)"? Attributes with those names > would be > automatically added to an instance, initialized to None, before the > first __init__ method would be called.
+0 on abstract attributes. Methods seem to dominate most APIs that make use of interfaces, but there are always a few exceptions. Attribute annotations could provide an elegant solution here. class ABC: concrete_attribute : "any expression" = None abstract_attribute : "any expression" I posted about attribute annotations before on python-ideas and there was lukewarm response. If anyone thinks a PEP on attribute annotations is worth submitting, let me know. Thanks -Tony _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com