3 ms·
But you can’t do that (or try/except) in an expression such as a list comprehension or similar.
by throwaway894345 6y ago
But you can’t do that (or try/except) in an expression such as a list comprehension or similar.
- robertlagrant 6y agoYes, because gross.
- deleted 6y ago[deleted]
- dragonwriter 6y agoNor, IMO, should you want to.
- throwaway894345 6y agoWhy not? Many other languages have closures and even Python has lambdas. Multi-line closures work well for these languages including in map/reduce/etc or comprehensions where applicable. Seems like your preference is overfit to Python’s limitations.
- robertlagrant 6y agoBecause you can do it in a function. It's not a limitation when you can do it. Having to define a function that's easier to read, and testable as an independent unit, is not a problem.