S
Sagari
Greetings,
Can someone suggest an efficient way of calling method whose name is
passed in a variable?
Given something like:
class X:
#...
def a(self):
# ...
def b(self):
# ...
#...
x = X()
#...
v = 'a'
How do I call the method of x whose name is stored in v?
PHP code for this would be:
class X {
function a() {
}
}
$x = new X();
$v = 'a';
$x->$v();
I need a solution for Python. Could you suggest anything?
The task it to call a function whose name is taken from user-supplied
input.
Thanks.
Can someone suggest an efficient way of calling method whose name is
passed in a variable?
Given something like:
class X:
#...
def a(self):
# ...
def b(self):
# ...
#...
x = X()
#...
v = 'a'
How do I call the method of x whose name is stored in v?
PHP code for this would be:
class X {
function a() {
}
}
$x = new X();
$v = 'a';
$x->$v();
I need a solution for Python. Could you suggest anything?
The task it to call a function whose name is taken from user-supplied
input.
Thanks.