Skip to main content
deleted 52 characters in body
Source Link
Inbar Rose
  • 43.7k
  • 24
  • 91
  • 137

Extract (refactor) your statements. And use the magic of and and or to decide when to short-circuit.

def a(): try:  # a code except: pass # or raise else: return True def b(): try:  # b code except: pass # or raise  else: return True  def c(): try:  # c code except: pass # or raise  else: return True  def d(): try:  # d code except: pass # or raise else: return True def main(): try: a()  and b()  or c()  or d() except: pass 

Extract (refactor) your statements.

def a(): try:  # a code except: pass # or raise def b(): try:  # b code except: pass # or raise def c(): try:  # c code except: pass # or raise def d(): try:  # d code except: pass # or raise def main(): try: a()  b()  c()  d() except: pass 

Extract (refactor) your statements. And use the magic of and and or to decide when to short-circuit.

def a(): try: # a code except: pass # or raise else: return True def b(): try: # b code except: pass # or raise  else: return True  def c(): try: # c code except: pass # or raise  else: return True  def d(): try: # d code except: pass # or raise else: return True def main(): try: a() and b() or c() or d() except: pass 
Source Link
Inbar Rose
  • 43.7k
  • 24
  • 91
  • 137

Extract (refactor) your statements.

def a(): try: # a code except: pass # or raise def b(): try: # b code except: pass # or raise def c(): try: # c code except: pass # or raise def d(): try: # d code except: pass # or raise def main(): try: a() b() c() d() except: pass