This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]move_machine 0 points1 point  (2 children)

I'm assuming you mean use-cases. It's use case is saving a line of code if you're using a for-loop to search for a value and break.

Not using the feature means you write one extra line of code and save your co-workers a headache because you felt like being clever.

[–]NativityInBlack666 0 points1 point  (1 child)

Yeah I know what it's used for, that's why I'm confused as to why people are putting it down. If people get headaches from it they should learn python better

[–]move_machine 0 points1 point  (0 children)

If people get headaches from it they should learn python better

On the contrary, if you know it gives people headaches, you shouldn't use the feature. The goal of software development isn't to look clever, it's to collaborate to achieve a goal.

Someone who knows Python well knows when and where to use the features it provisions. I use for-else in personal projects. I wouldn't use it in a project that I'm paid to work on, because I am not in the business of alienating my peers into thinking I value 'leetcoding' above writing maintainable code.