I am one of these programmers. One reason is when i scan code, and often miss an else/elif clause. I find the standard more structured, and noticeable. Now i like how python makes things condensed compared to other languages. But in some cases that feature turns into hinderance. This is also the reason i tend to stay away from list comps. I find it looks more cluttered. Even though its a little faster, i like the more readable standard approach. But thats just my option. Good post though!

Haha. Thankyou. I also love comprehensions. I think the time I spent doing some of the problems on Project Euler ruined me though. I like to try to turn complex algorithms into one-liners whenever possible. I will be the first to admit that at its worst this certainly doesn't aid readability and is far from Pythonic.

Again, it is more concise but it hides the conditional that would otherwise be there.

Due to the reasons discussed here we will be moving to python-forum.io on October 1st, 2016.This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.

I do use the ternary operator, although I just looked at my code to give an example and when I was reading it I realized the code was incorrect... so I certainly can't defend it!

ichabod that's terrible! (I've done it before too, but I learned better! Especially since there's a ternary operator now, if you really wanted to do that).

Mekire, in your original post, I find the spacing (or lack thereof) in the first ternary example to be very confusing, as it implies that the += occurs or 2 does, rather than the += being applied to the whole right hand side.

It just seems that choosing between two values for a single variable is a waste of a good conditional.

Due to the reasons discussed here we will be moving to python-forum.io on October 1st, 2016.This forum will be locked down and no one will be able to post/edit/create threads, etc. here from thereafter. Please create an account at the new site to continue discussion.