On 25/04/17 23:05, Paul Moore wrote:
- Writing out the assignments "longhand" is an unacceptable burden.
There are reasons why augmented assignment was implemented. One of them was to make the code easier to read:
foil = foil + 1 foil = foi1 + 1 foil += 1
Should one be silly enough to have a "foil" and "foi1" variable in scope, only one of those is clearly incrementing a variable without requiring a slightly harder look ;)
It's not about the time taken to type the line. It's about the clarity of what the line is expressing.
- Using a decorator (which can be written directly in your project,
doesn't even need to be an external dependency) is unacceptable.
All of the decorators (or other language tricks that modify the object's dict) suggested so far assume that ALL of the method's arguments are to be assigned. I do not want that. I want to be able to say:
def __init__(self, foo, bar, baz, spam): self .= foo, bar, spam self.baz = baz * 100
It's all still explicit inside the body of the method.
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"
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.
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 ;)