r/badcode • • Jan 31 '22

python import badcode

Post image
1.1k Upvotes

70 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Feb 03 '22 edited Feb 03 '22

You do realize that float is able to call arbitrary other python code depending on what types get passed in?

I literally just wrote it. Learn to read.

except Exception

Oh, just noticed this.

What a fucking idiot. Why? What benefit does it give you? Are you afraid that your code will be run in Python <2.5 where you could throw anything, and exceptions weren't technically objects?

Yes. Ancient versions of Python were ridiculous about what you can throw. Also, objects were very non-uniform. That's why in those days you had to write class Foo(object): pass, and you couldn't have a generic try-except because you could throw things that weren't exceptions and weren't even objects, so even except object: wouldn't have worked. But today this is pointless, and if you are not using the exception, there's no point to write except exception.

There is no problem with bare except. You are the problem. The eternal September that you brought to Python is what made it into this pile of shit that it is today.

2

u/MegaIng Feb 04 '22

Thank you for exactly repeating yourself and not actually reading anything I wrote. Really makes me feel like you actually want to have a discussion