Home Ask Login Register

Developers Planet

Your answer is one click away!

user7364359 January 2017

How do i call two of three existent functions randomly

I use of 3 functions with arguments in Python: Func1(a,b), Func2(c,d), Func3(e,f) . all i want is how to call two different functions of these three functions randomly. i have the below code for calling a function randomly too. how could i convert this code to that one which call 2 functions (which is not the same) randomly.

Mylist = [functools.partial(Func1, a, b), functools.partial(Func2, c, d), functools.partial(Func3, e, f)] random.choice(Mylist)()


Dan D. January 2017

Use random.sample:

for func in random.sample(Mylist, 2):

Post Status

Asked in January 2017
Viewed 2,897 times
Voted 12
Answered 1 times


Leave an answer

Quote of the day: live life