Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.python Subject: Re: Odd ValueError using float Date: Fri, 13 Mar 2015 19:33:20 -0700 Organization: A noiseless patient Spider Lines: 11 Message-ID: <877fuk71fz.fsf@nightsong.com> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="c694756f1077760bb5296aae16c74092"; logging-data="3113"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ng53ZgAIfFjp8zUj8QZFu" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:uK/yFAw6VDbsxQc1pzLv39LJr8g= sha1:DlGqX3DKT30phlYTRirpORviyvs= Xref: csiph.com comp.lang.python:87403 emile writes: > *** NameError: name 'val' is not defined > (Pdb) l > 139 try: > 140 val = round(float(decval),1) > 141 except: > 142 import pdb; pdb.set_trace() If 'float' or 'round' throw an exception, the assignment to 'val' never happens, so 'val' is undefined. Try examining the value of 'decval' in the debugger to see what is making the conversion fail.