3 ms·
"Stop trying to shorten code by 2 lines." Agreed. Python code tends to be concise as is. There's no need to add little tricks to cut out a line or two at the e
by CurlyJefferson 8y ago
"Stop trying to shorten code by 2 lines."
Agreed. Python code tends to be concise as is. There's no need to add little tricks to cut out a line or two at the expense of readability.
Along those lines, in a recent code review a developer balked at some proposed code and boasted how he could do the same thing in fewer lines. His "improved" code had a keyword parameter where the default was set to a lambda function containing nested list comprehensions plus a zip function... I voted against his "improvement" since it was the most unpythonic thing I'd ever seen. I'll take added readability and simplicity at the expense of a few extra lines.
- talltimtom 8y ago> Agreed. Python code tends to be concise as is. There's no need to add little tricks to cut out a line or two at the expense of readability. I must say I agree fully, and even so, in cases where you really want to cut down verbose sections or boilerplate, there is so much you can do through defining your own classes and functions and overloading operators. Even then there is little need for new fundamental syntax.