[Tutor] eval func with floating...

Christopher King g.nius.ck at gmail.com
Wed Aug 24 02:43:11 CEST 2011


>     if c:
>         print *eval("float(%s)"%a)*
>     else:
>         print "error! please use -defined operators-!"
>
I would use a assert statement for more readability, like so.
*try: assert c*
*except AssertionError: print "error! please use -defined operators-!"*
else: *print *eval("float(%s)"%a)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110823/3b9c76b7/attachment.html>


More information about the Tutor mailing list