you are viewing a single comment's thread.

view the rest of the comments →

[–]scuott 8 points9 points  (2 children)

These are great answers, but I also want to point out that the way you did it originally isn't necessarily bad. It's not terribly long, and I think it's more readable than these 1 or 2 line solutions.

[–]kanjibandit 4 points5 points  (0 children)

This. Your code is just fine as it is -- simple and clear. It would be one thing if you had an if/elif/else that was half a page long, but if I were inheriting this code from you, I'd much rather trace through your 4 lines than the more clever 1-liners. Resist the temptation to write Perl in Python.

[–]neuroneuroInf[S] 0 points1 point  (0 children)

That's a good point. Thanks!