[Python-ideas] Augmented assignment syntax for objects.

Nathaniel Smith njs at pobox.com
Tue Apr 25 00:04:40 EDT 2017


On Mon, Apr 24, 2017 at 6:08 PM, Erik <python at lucidity.plus.com> wrote:
> Hi. I suspect that this may have been discussed to death at some point in
> the past, but I've done some searching and I didn't come up with much.
> Apologies if I'm rehashing an old argument ;)
>
> I often find myself writing __init__ methods of the form:
>
> def __init__(self, foo, bar, baz, spam, ham):
>   self.foo = foo
>   self.bar = bar
>   self.baz = baz
>   self.spam = spam
>   self.ham = ham

This isn't a direct response, but you might be interested in the attrs library:
    https://attrs.readthedocs.io/en/stable/examples.html

-n

-- 
Nathaniel J. Smith -- https://vorpus.org


More information about the Python-ideas mailing list