I'm relatively new to programming so I beg your pardon if I'm making a ridiculous mistake by referring to the following as Duck Typing.
I have a procedure which receives either a string or a tuple (containing strings) as a single argument.
Example:
def proc(arg):
try:
arg is a tuple
handle arg a tuple
except:
arg is a simple string
handle it so
Depending on whether the argument is a tuple or not, I want the function to behave differently.
I do not want to type check and would like to use a try..except
process.
I thought about trying arg[0]
but strings in Python are objects as well and in that regard they behave like tuples and return something.
What can I do here?
Thank you.