More pythonic way to change an element of a tuple?

Richard Muller rpm at wag.caltech.edu
Wed Nov 27 12:58:44 EST 2002


I frequently have to change a single element of a tuple, and I wind up 
doing something like this:

tmp = list(data_in_tuple)
tmp[item] += 1
data_in_tuple = tuple(tmp)

Is there a more beautiful way of doing this? Seems a bit awkward.

Thanks in advance,

Rick




More information about the Python-list mailing list