My function expects a list or a tuple as a parameter. It doesn't really care which it is, all it does is pass it to another function that accepts either a list or tuple:
def func(arg): # arg is tuple or listanother_func(x)# do other stuff here
Now I need to modify the function slightly, to process an additional element:
def func(arg): #arg is tuple or listanother_func(x + ['a'])# etc
Unfortunately this is not going to work: if arg is tuple, I must say x + ('a',)
.
Obviously, I can make it work by coercing arg to list. But it isn't neat.
Is there a better way of doing that? I can't force callers to always pass a tuple, of course, since it simply shifts to work to them.