normal way:
for x in myList:
myFunc(x)
you must use a variable x
use
map(myFunc,myList)
and in fact you must use this to make above work
list(map(myFunc,myList))
that would build a list,i don’t need to build a list
maybe some one would suggest me doing this
def func(l):
for x in l:
....
that is another topic
is there something like this?
every(func,myList)
The ‘normal way’ is definitely the best way, although
itertoolsdoes offer the consume recipe for whatever reason you might need it:This could be used like:
This function performs the fastest as it avoids python for loop overhead by using functions which run on the C side.