sending string or list to a function

manstey manstey at csu.edu.au
Mon Dec 4 19:20:26 EST 2006


Hi,

Is there a neat way to write a function that can receive either a
string or a list of strings, and then if it receives a string it
manipulates that, otherwise it manipulates each string in the list?

That is, rather than having to send a list of one member
MyFunction(['var1']), I can send

MyFunction('var1')  or MyFunction(['var1','var2',var3'])

Or is this bad programming style?

What do you think?




More information about the Python-list mailing list