lundi 7 mars 2022

What is the best way to implement this Python code

I have this simple code here:

def myFunction(a: my_enumA, b: my_enumB, c: my_enumC):
  
  if a:
    update_a = update_from_db_a(a=a)
  else:
    update_a = True
  
  if b:
    update_b = update_from_db_b(b=b)
  else:
    update_b = True
  
  if c:
    update_c = update_from_db_c(c=c)
  else:
    update_c = True
    
  if update_a and update_b and update_c:
    return True
  else:
    return False

I'm sure that a design patern exists for this but I don't know the name.

What is the best way Pythonic way to implement it ? Maybe with a design pattern?

Aucun commentaire:

Enregistrer un commentaire