Python : Call function using string (similar to Java Reflection API )
# Calling
class animals:
def dog(self):
print("bark")
def lion(self):
print("roar")
obj=getattr(animals(),'dog')
obj()
class animals:
def dog(self):
print("bark")
def lion(self):
print("roar")
obj=getattr(animals(),'dog')
obj()
result :
bark
A great content and very much useful to the visitors. Looking for more updates in future.
ReplyDeletePYTHON Training in Chennai