this post was submitted on 12 May 2024
512 points (97.2% liked)

Programmer Humor

31217 readers
41 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 4 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 77 points 1 month ago (28 children)

Meme is funny, but that exception used as flow control hurts.

[–] [email protected] 38 points 1 month ago (21 children)

Tbf python guidelines encourage it over if/else in cases like this. "Easier to ask for forgiveness than for permission" or something along the lines

[–] [email protected] 10 points 1 month ago (2 children)

python guidelines

Do you have a specific PEP you're referencing or is this one of those "I assume this must be the case because of how common using try/except statements for flow control are" kind of things?

[–] [email protected] 4 points 1 month ago (1 children)

Pretty sure its not a PEP, but the python glossary mentions it. Searching 'python EAFP' brings up a lot of discussion on the topic too, so if nothing else its definitely a widespread phenomenon

[–] [email protected] 1 points 1 month ago

I think there's a difference between "python guidelines encourage" something and "this is a common coding pattern." Yes, you can use try/except for flow control, but there's a lot of people, myself included, who try to use that style sparingly.

load more comments (18 replies)
load more comments (24 replies)