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

Terry Reedy tjreedy at udel.edu
Sun Jul 10 22:26:24 CEST 2005

"Ralf W. Grosse-Kunstleve" <rwgk at yahoo.com> wrote in message 
news:20050710133959.83611.qmail at web31512.mail.mud.yahoo.com...

I have a suggestion I don't remember seeing for flagging which vars to 
autoinit without new syntax: use '_' instead of '.'.  I have never seen 
local vars with a leading '_'.  So, in combination with whatever other 
mechanism (metaclass, __init__ decorator?)

   def __init__(self, _x, y, _z) :

would automatically do self.x = _x, self.z = _z, but not self.y = y.

Terry J. Reedy

More information about the Python-list mailing list