On Sun, 10 Feb 2013 16:27:49 -0500 PJ Eby <p...@telecommunity.com> wrote: > On Sun, Feb 10, 2013 at 7:32 AM, Nick Coghlan <ncogh...@gmail.com> wrote: > > class Example: > > @classmethod > > def __init_class__(cls): > > Is the @classmethod required? What happens if it's not present? > > Second, will type have a default __init_class__? (IMO, it should, > otherwise it will be impossible to write co-operative __init_class__ > functions.) > > Only other comment is that the PEP could use a more concrete use case, e.g.: > > class Record: > __fields = {} > > @classmethod > def __init_class__(cls): > cls.__fields = dict(cls.__fields) # inherited fields > cls.__fields.update({attr:val for attr, val in > cls.__dict__.iteritems() if isinstance(val, Field)}) > super().__init_class__() # be co-operative > > # ...other methods that use the __fields attribute > > class SomeRecord(Record): > foo = Field(int) > bar = Field(str) > > Putting something like this early on might help to demonstrate the > usefulness of the feature on its own merits, independent of the > porting issue, etc. ;-)
Can you explain what the example does / is supposed to do? _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com