[Python-ideas] Augmented assignment syntax for objects.

Mike Miller python-ideas at mgmiller.net
Wed Apr 26 14:15:18 EDT 2017


On 2017-04-25 15:05, Paul Moore wrote:
> It seems to me that the number of people for whom both of the following hold:
>
> 1. Writing out the assignments "longhand" is an unacceptable burden.
> 2. Using a decorator (which can be written directly in your project,
> doesn't even need to be an external dependency) is unacceptable.
>
> is likely to be small enough that it's not a compelling argument for
> adding new syntax. Add to that the fact that these people would be
> arguing "I want the ability to avoid writing out the assignments, but
> I don't want that capability enough to use a decorator" - which hardly
> says that a syntax change is vital - and it's difficult to see this
> proposal getting accepted.

While the word unacceptable is probably a bit too strong, this is a good 
insight.  We have a "middling" difficulty here.  Not the end of the world, but 
an annoyance, as the existence of the attrs library demonstrates.  Kivy's 
properties solve a similar problem (though a bit different scope).  I've 
overheard Java snobs sneer at Python's init so it is a well known issue.

If there is going to be a solution, I submit it needs to be much easier to use 
and to read.  Making it a little easier is not good enough, not enough reason to 
change.  (Believe you mentioned a 3 to 2 reduction elsewhere in the thread.)  Meh.

If I have install a module in pip and go back to the top of the file and write 
an import line and then come back and write out a decorator it's not going to be 
worth it.  Currently, I use editor snippets to ease authoring of init, but 
readability and DRY are still concerns afterward.

As the new syntax ideas piggyback on existing syntax, it doesn't feel like that 
its a complete impossibility to have this solved.  Could be another "fixed 
papercut" to drive Py3 adoption.  Taken individually not a big deal but they add up.


More information about the Python-ideas mailing list