On 26/12/2014 1:37 PM, Steven D'Aprano wrote:
One approach is to use a function in the condition to do the assignment:
Let me fix that for you:
/s/approach/bad idea/
I never said it was a _good_ approach ;)
And you don't even save any lines! Instead of a one-liner, you have six
lines!
While I'm _definitely_ not going to advocate for this approach as a
valid solution, I have to disagree with this being an issue. While it's
more lines in the given example, if there were dozens of such
assignment-within-conditional calls in the same code, the additional
LOCs become negligible.
Just because a programming language allows something doesn't make it a good
idea.
This is true. But conversely, just because I think something is a bad
idea doesn't mean someone else can't have found a valid use for it.
--
https://mail.python.org/mailman/listinfo/python-list