
On 25 April 2017 at 23:30, Erik <python@lucidity.plus.com> wrote:
As I said above, it's not about the effort writing it out. It's about the effort (and accuracy) of reading the code after it has been written.
Well, personally I find all of the syntax proposals relatively unreadable. So that's definitely a matter of opinion. And the "explicit is better than implicit" principle argues for the longhand form. As has been pointed out, the case for += is more about incremented complex computed cases than simply avoiding repeating a variable name (although some people find that simpler case helpful, too - I'm personally ambivalent).
And as I also said above, decorators don't cut it anyway (at least not those proposed) because they blindly assign ALL of the arguments. I'm more than happy to hear of something that solves both of those problems without needing syntax changes though, as that means I can have it today ;)
That's something that wasn't clear from your original post, but you're correct. It should be possible to modify the decorator to take a list of the variable names you want to assign, but I suspect you won't like that - it does reduce the number of times you have to name the variables from 3 to 2, the same as your proposal, though. class MyClass: @auto_args('a', 'b') def __init__(self, a, b, c=None): pass Paul