DEV Community

Discussion on: 3 Common Mistakes that Python Newbies Make

Collapse
 
vlasales profile image
Vlastimil Pospichal

Negative comparisons are needed to eliminate else from source codes.

Thread Thread
 
rpalo profile image
Ryan Palo

I’m not 100% sure that else is a bad thing. But I agree that using negative comparisons isn’t a terrible thing. Maybe more of a “all things being equal, try to use positive rather than negative if possible” kind of thing.

Thread Thread
 
vlasales profile image
Vlastimil Pospichal

Eliminating else made my source code cleaner and faster. I use else in ternary operator only. I transformed structure if-else into ternary expression in many times.

Some languages (XSLT for example) are without "else". This inspired me.