Thanks to everyone for the advice. In fact, since all the called
methods trap necessary exceptions, I see no big problems with that.
With all respect,
Konstantin
--
http://mail.python.org/mailman/listinfo/python-list
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
> Nick Craig-Wood a ?crit :
> > Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
> >>> Can someone suggest an efficient way of calling method whose name is
> >>> passed in a variable?
> >>>
> >> method = getattr(obj, 'method_name', None)
> >> if calla
Nick Craig-Wood a écrit :
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
Can someone suggest an efficient way of calling method whose name is
passed in a variable?
method = getattr(obj, 'method_name', None)
if callable(method):
method(args)
I think that that is needless LBYL...
Fro
Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
> > Can someone suggest an efficient way of calling method whose name is
> > passed in a variable?
> >
>
> method = getattr(obj, 'method_name', None)
> if callable(method):
> method(args)
I think that that is needless LBYL...
getattr(obj
Sagari a écrit :
Greetings,
Can someone suggest an efficient way of calling method whose name is
passed in a variable?
method = getattr(obj, 'method_name', None)
if callable(method):
method(args)
--
http://mail.python.org/mailman/listinfo/python-list
Sagari wrote:
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?
Use get
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: