samedi 23 février 2019

How to avoid multiple times if elif elif else condition using python design pattern and solid principle

  • I want to refactor the code using python design pattern and solid principle.

  • In my code there are multiple if elif elif else conditions. but i want to remove the multiple if elif condition

    if self.description and self.bank and self.split:
        print("India")
    elif self.train:
        print("Maharashtra")
    elif self.split:
        print("Pune")
    else:
        print("Mumbai)
    
    

How can i refactor the multple if elif elif else condition using python solid principles and design patterns?

Aucun commentaire:

Enregistrer un commentaire