Hacker News new | ask | show | jobs
by Svetlitski 958 days ago
> This will lead to hard to read code

I’m curious to hear why you think this. What is it about duplicating the variable name that you feel makes the code clearer?

1 comments

It's clearer because with the duplicated variable name, the syntax is just a special case of the general default argument syntax. The default value for the "visibility" parameter is the value of the "visibility" variable in the scope the function belongs to. Anyone who knows the default argument syntax can work that out. And even if you don't know the default argument syntax, you might be able to guess how it works by analogizing it to the similar-looking variable assignment syntax. With the new syntax, on the other hand, you have to know about it in order to understand what it does. It just adds one more thing people will have to learn about Python syntax, for, as far as I can see, a very minor benefit. The trade-off doesn't seem worth it to me, given that one of Python's USPs is its relative accessibility to newcomers.