Victor Subervi wrote:
Hi;
I have a string.join statement on a variable that comes from a cgi.FieldStorage().getlist. The variable may be a list or a single value. I need to treat it differently depending on which it is. How can I distinguish it? len(var) will obviously give me the length of the string if it's a string and the length of the list if it's a list.

1. string.join isn't a statement, it's a function, and why are you using
it anyway? Strings have a .join method:

>>> ", ".join(["first", "second", "third"])
'first, second, third'

2. Are you sure cgi.FieldStorage().getlist sometimes returns a single
value instead of a list? If that's the case then it's a very odd name
for the method!
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to