I'm wondering whether there are any good reasons to prefer a list over a tuple or vice versa in python if
statments. So the following are functionally equivalent but is one preferable to the other in terms of performance and coding style or does it not matter?
if x in (1,2,3):
foo()
if x in [1,2,3]:
foo()
I seem to have gotten into the habit of using tuples if there are 2 or 3 values and lists for anything longer, I think because in my experience tuples tend to be short and lists long, but this seems a bit arbitrary and probably needlessly inconsistent.
I'd be interested in any examples people can give of where one would be better than the other.
Cheers