My goal is to write a class that should allow me to determine which method to call ( A1 or A2 ) while creating an object p. C will call B, B will call A.
def A1():
return 'A1_g'
def A2():
return 'A2_g'
class test:
def __init__(self, means=None):
self.means=means
def A1(self):
return 'A1'
def A2(self):
return 'A2'
def B(self,A):
new_string='methodB called '+A()
print new_string
def C(self):
q=self.B(self.means)
return q
p=test(means=A1)
p.C()
I got this output "methodB called A1_g". But I want "methodB called A1"
If I delete the top 2 fn definition, I got "NameError: name 'A1' is not defined". Want to understand how and why to achieve this.
A1as a string.