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

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -