I have object a of class b with methods foo(), boo(), noo(arg). Now I want to randomly choose one of them without extending the class b. The problem is that if I use technics supposed here: Syntax to call random function from a list , then I have to have the same arguments of my methods. So I can't use smth like this:
my_list = [a.foo, a.boo, a.noo]
random.choice(my_list)()
I case of noo method I need to call it with arg: a.noo(arg). So how to do it in pythonic way?
Aucun commentaire:
Enregistrer un commentaire