Quantcast
Channel: Catching exceptions in else - Stack Overflow
Browsing index pages (2 articles)
↧

Catching exceptions in else

Is this a good pythonic way to test something for equality, and catch exceptions in else?try: # Check for equality debug.assert_eq(data, None) debug.assert_eq(id, None) debug.assert_eq(time, None)...

View Article


Answer by Martijn Pieters for Catching exceptions in else

Your logic is rather.. involved. If you want to test if at least one of those variables is not None, then use any():debug.assert(any(v is not None for v in (data, id, time, group)))any() iterates over...

View Article

Browsing index pages (2 articles)


Latest Images