__autoinit__ (Was: Proposal: reducing self.x=x; self.y=y; self.z=z boilerplate code)

Kay Schluehr kay.schluehr at gmx.net
Sun Jul 10 01:11:38 EDT 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):
>       pass

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):
>       pass
>
> I think that's far more intuitive.

Being intuitive is relative to someones intuition. 

Kay




More information about the Python-list mailing list