samedi 4 août 2018

How to use multiple conditions using a class method in if else condition in python

Here I want to use those 2 methods (method1 and 2) below within same class. (to simplify what I'm trying todo)

class Class1():
   def method1(self): 
     ----
     ----

   def method2(self):
     ----
     ----

   def method3(self):
     if A == A and self.method1:
       print ("method1 success")

     elif B == B and self.method2:
       print ("method2a success")

     elif A == A and self.method2:
       print ("method2b success")

     else
       print ("failed")

however every time i try to run the code and want to fall in method3 elif condition (method2a or 2b) it always fall on if (method1)

Am I missing something on my if..else condition?

Aucun commentaire:

Enregistrer un commentaire