#------------------------------------
#CLASS
#------------------------------------
class Student:
def __init__(self):
self.name = None
def set_name(self, word):
self.name = word
return self.get_name()
def get_name(self):
return self.name
#------------------------------------
# USAGE:
#------------------------------------
a = Student()
print(a.set_name("Hello"))
import foo
method_to_call = getattr(foo, 'bar')
result = method_to_call()
class A:
def __init__(self):
pass
def sampleFunc(self, arg):
print('you called sampleFunc({})'.format(arg))
m = globals()['A']()
func = getattr(m, 'sampleFunc')
func('sample arg')
# Sample, all on one line
getattr(globals()['A'](), 'sampleFunc')('sample arg')
result = getattr(foo, 'bar')()