questions about Exceptions?

cokofreedom at gmail.com cokofreedom at gmail.com
Thu Apr 10 06:38:38 EDT 2008


> def Calc():
>     global nbr
>     try:
>         print eval(nbr)
>         #a = Label(mygui, text=eval(nbr))
>         #a.place(relx=0.4, rely=0.1, anchor=CENTER)
>     except:
>         print "Not computable"
>     nbr = ""
>
> def Erase():
>     global nbr
>     nbr = ""

Seems to me you could be better off passing a parameter and a return
statement of None (or your parameter cleaned) for those functions,
which should work. Given an input, Eval it and then return None. That
way you wouldn't need the Erase...



More information about the Python-list mailing list