DEV Community


Discussion on: Advanced Python: for more attractive code

sayanarijit profile image
Arijit Basu

I think you could have used better terms than beginner and advanced as some of the examples you mentioned doesn't distinct beginners and advanced programmers.

For example, a lot of times it's much cleaner to use plain loops and conditions instead of comprehension and single line if else. Cleanliness is very important. Similarly important is making sure that the person reading your code understands it. So, experts would rather never use else with for loops.

However, as a beginner tutorial I think it's fine.

burdier profile image

I agree with you.

teosoft7 profile image
Taeho Jeon Author

Thanks for the feedback. I agree with you.

detinsley1s profile image
Daniel Tinsley

I think it depends on how complicated the comprehension or the ternary expression is. If it's hard to comprehend, then a loop or an if...elif...else statement would be better, but if it's a simple statement, then a comprehension or ternary expression is just as good and is more Pythonic.