One cannot in good faith argue that the duck typing approach in the following answer is a sensible practice.https://stackoverflow.com/a/1952655
-
-
Show this thread
-
In fact, I'd go so far as to argue that the try-except-else pattern is *fucking nonsense* that is at best a corruption of a different pattern to wallpaper over a hole in a wall.
Show this thread -
In case you're wondering why this is bad: - You're assigning a variable you intend to do nothing with - You're forcing yourself into eating an exception - If you want to check for actual exceptions, you need yet more code - try-except patterns aren't for type checking
Show this thread
End of conversation
New conversation -
-
-
The typical approach in the standard library is to just iterate, and let the exception escape if iteration isn't supported. Folks coming from statically typed languages tend not to like how many checks we defer to runtime :)
-
(This is also the origin of core devs recommendation to drop out of Python and into something less dynamic once you identify performance bottlenecks, though)
End of conversation
New conversation -
-
-
I'm trying to figure out what of those 'best' practices are marketable to people hiring new developers, since I've learned that saying 'monadic' is a great way to not get written back to~
- 1 more reply
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.