are the both approaches equivalent from a point of view of performance and coding-style?
def foo(n):
return n*2
# case 1 with ".append(function())"
mylist = [1,2,3,4,5,6,7,8,9,10]
result = list()
for l in mylist:
result.append(foo(l))
# case 2 ".append(result)"
mylist = [1,2,3,4,5,6,7,8,9,10]
result = list()
for l in mylist:
r = foo(l)
result.append(r)
=
, coding!=
first better, but Python supports much better ways.. – Grijesh Chauhan Mar 10 '13 at 17:52