Length of an Unsized Object
Victor Subervi
victorsubervi at gmail.com
Thu Dec 31 12:08:33 EST 2009
On Thu, Dec 31, 2009 at 12:01 PM, Stephen Hansen <apt.shansen at gmail.com>wrote:
> On Thu, Dec 31, 2009 at 8:09 AM, Victor Subervi <victorsubervi at gmail.com>wrote:
>
>> Hi;
>> I have this code:
>>
>> sql = 'describe %s %s;' % (optionsStore, option)
>> print sql
>> cursor.execute(sql)
>> descr = cursor.fetchone()
>> if len(descr) is not None:
>>
>> Python complains:
>>
>> *TypeError*: len() of unsized object
>>
>> Please advise how to rewrite the last line so as to avoid the infamous
>> try/except.
>>
>
> The test itself makes no sense; len returns an integer, and can never be
> None.
>
> Simply do:
>
> if descr:
>
Thanks, Steven.
beno
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091231/8ae14d90/attachment-0001.html>
More information about the Python-list
mailing list