I have a class with some functions, like this:
class valami:
def a():
*some code...*
def b():
*some code...*
def c():
*some code...*
I want to choose a random function from the valami calss. I already tried this:
random.choice((valami.a(), valami.b(), valami.c()))
But it called all the functions at same time.
Don't call them right away, only call the function that the code randomly chose:
random.choice((valami.a, valami.b, valami.c))()
If you don't want to call it yet, just remove the pair of parenthesis at the end, make it become:
random.choice((valami.a, valami.b, valami.c))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With