On 1/14/2014 5:42 AM, Albert-Jan Roskam wrote:
I also found that item assignment ([1] below) is much faster
> than using the more standard (I think) .append ([2]).
# [1] for idx,item in enumerate(L[:]): if some_condition: L[idx] = foobarify(item)
[1] *is* the standard way to selectively replace items.
# [2] L2 = [] for idx,item in enumerate(L): if some_condition: L2.append(foobarify(item)) else: L2.append(item)
-- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list