functional programming - Repeat function a couple times without for loop in python -
is there way repeat function (and generate tuple) in python 2?
i'm hoping syntax looks like:
x, y = repeat(fxn, 2)
where fxn
takes no arguments , 2
length of output tuple.
you can use generator expressions:
x, y = (fxn() _ in range(2))
Comments
Post a Comment