Christopher King wrote:
    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)


Only if you want the user to be able to turn off error checking and break your program.

"python -O" switches off all assertions.

Do not use asserts except for assertions about internal states of your program. Never, ever use them for testing user input, or for reporting errors to the user. That is not what they are for. If the user ever sees an AssertionError, your code is buggy.



--
Steven
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to