__autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)
kay.schluehr at gmx.net
Sun Jul 10 07:11:38 CEST 2005
> I stripped your code down to the essence. See attachment.
> For the user your approach then becomes:
> class grouping:
> __metaclass__ = autoattr
> def __init__(self, x, y, z):
No. This is clearly NOT what I had in mind. I translated your original
proposal which introduced a punctuation syntax '.x' for constructor
parameters forcing the interpreter to create equally named object
attributes into a naming convention that can be handled by a metaclass
customizer. The grouping.__init__ above does exacly nothing according
to my implementation. I would never accept dropping fine-tuning
capabilities. The "auto_" prefix is all the declarative magic.
> My __autoinit__ suggestion would result in (assuming object supports
> this by default):
> class grouping(object):
> def __autoinit__(self, x, y, z):
> I think that's far more intuitive.
Being intuitive is relative to someones intuition.
More information about the Python-list