Easy Q

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Jan 13 06:58:00 CET 2010

En Sat, 09 Jan 2010 13:11:28 -0300, Victor Subervi  
<victorsubervi at gmail.com> escribió:

> 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.

Are you sure you have tested with getlist()?
getlist() *always* returns a list: an empty one, a list containing a  
single item, or many items. getvalue() on the other hand may return None,  
a single item, or a list.

Gabriel Genellina

More information about the Python-list mailing list