[Python-ideas] Augmented assignment syntax for objects.

Mike Miller python-ideas at mgmiller.net
Tue Apr 25 14:16:22 EDT 2017


Agreed with Steven, although I do find myself a little more annoyed and bothered 
by a typical init than him I guess.

Even so I didn't think the current proposals went far enough.  To tilt the 
balance farther, to make it easier, let's go all the way!  Instead of continuing 
duplication:

> >>> def __init__(self, foo, bar, baz, spam, ham):
>   self .= foo, bar, baz, spam, ham

or

> # object member assignment
> self .= foo .= bar .= baz .= spam .= ham

How about?

     def __init__(self, foo, bar, baz, spam, ham):
       self .= *

The asterisk here used to be reminiscent of argument unpacking (minus self). 
That would imply a double asterisk for keyword assignment which could be used as 
well.

Also, I did find the decorator proposal intriguing, though have to say I 
probably wouldn't bother to use it unless it were a builtin or I had a dozen 
parameters to deal with.

-Mike


More information about the Python-ideas mailing list