Easy Q

Victor Subervi victorsubervi at gmail.com
Mon Jan 11 09:20:33 EST 2010


On Mon, Jan 11, 2010 at 10:00 AM, Jean-Michel Pichavant <
jeanmichel at sequans.com> wrote:

> Victor Subervi wrote:
>
>  On Sat, Jan 9, 2010 at 11:56 AM, Gary Herron <gherron at islandtraining.com<mailto:
>> gherron at islandtraining.com>> wrote:
>>
>>    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.
>>        TIA,
>>        beno
>>
>>
>>    Like this:
>>
>>    if isinstance(var, list):
>>     ... join ...
>>    else:
>>     ... ??? ...
>>
>>
>> Right.. Thanks!
>> beno
>>
> You should definitely check again MRAB's answer.
> Having getlist returning something else than a list, especially a non
> iterable single item *is* suspicious.
> Usually, properly designed functions return consistent types over calls.
>

Obviously. Thanks,
beno
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100111/1782eed9/attachment.html>


More information about the Python-list mailing list