Functions help
sffjunkie at gmail.com
sffjunkie at gmail.com
Mon Feb 24 05:32:07 EST 2014
On Sunday, 23 February 2014 05:43:17 UTC, Scott W Dunning wrote:
> I had a question regarding functions. Is there a way to call a function multiple times without recalling it over and over. Meaning is there a way I can call a function and then add *5 or something like that?
The following answers your question but is probably not a method you want to employ.
from functools import partial
def a(ch):
print(ch)
def b(x):
print(x + 4)
[x() for x in [partial(a, 'd'), partial(b, 10)]*5]
Produces
d
14
d
14
d
14
d
14
d
14
--Simon
More information about the Python-list
mailing list