On Thu, Mar 24, 2016, at 10:49, BartC wrote: > On 24/03/2016 14:34, Jussi Piitulainen wrote: > > You understand correctly, but it may be more natural in practice to > > write it this way: > > > > for k, item in enumerate(them): > > them[k] = f(item) > > > > I _think_ I might write it that way even when "f(item)" does not depend > > on the old value at all, but I don't expect to be in that situation. > > > > Yes, you're right. Usually the update is conditional on the existing > value. But my too-simple example would have had an unneeded item > variable.
How about them[:] = map(f, them)? -- https://mail.python.org/mailman/listinfo/python-list