On Thu, Dec 31, 2009 at 8:09 AM, Victor Subervi <span dir="ltr"><<a href="mailto:victorsubervi@gmail.com">victorsubervi@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Hi;<br>I have this code:<br><br>        sql = 'describe %s %s;' % (optionsStore, option)<br>        print sql<br>        cursor.execute(sql)<br>        descr = cursor.fetchone()<br>        if len(descr) is not None:<br>


<br>Python complains:<br><br><strong>TypeError</strong>: len() of unsized object
<br><br>Please advise how to rewrite the last line so as to avoid the infamous try/except.<br></blockquote><div><br></div><div>The test itself makes no sense; len returns an integer, and can never be None.</div><div> </div>

<div>Simply do:</div><div><br></div><div>   if descr:</div><div><br></div><div>HTH,</div><div><br></div><div>--S</div><div><br></div></div>