On 25/04/17 02:15, Chris Angelico wrote:
Bikeshedding: Your example looks a lot more like tuple assignment than
multiple assignment.

Well, originally, I thought it was just the spelling-the-same-name-twice thing that irritated me and I was just going to suggest a single assignment version like:

  self .= foo
  self .= bar

Then I thought that this is similar to importing (referencing an object from one namespace in another under the same name). In that scenario, instead of:

  from other import foo
  from other import bar

we have:

  from other import foo, bar

That's where the comma-separated idea came from, and I understand it looks like a tuple (which is why I explicitly mentioned that) but it does in the import syntax too ;)

The single argument version (though it doesn't help with vertical space) still reads better to me for the same reason that augmented assignment is clearer - there is no need to mentally parse that the same name is being used on both sides of the assignment because it's only spelled once.

self .= foo .= bar .= baz .= spam .= ham

Thanks for being the only person so far to understand that I don't necessarily want to bind ALL of the __init__ parameters to the object, just the ones I explicitly reference, but I'm not convinced by this suggestion. In chained assignment the thing on the RHS is bound to each name to the left of it and that is really not happening here.

The trouble is that this syntax is really only going to be used inside
__init__.

Even if that was true, who ever writes one of those? :D

E.
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to