""" return number * number >>> square_this(3) 9 >>> square_this(“number”) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 2, in square_this TypeError: can't multiply sequence by non-int of type 'str'
>>> square_this(3) 9 >>> square_this(“number”) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 2, in square_this TypeError: can't multiply sequence by non-int of type 'str'
>>> square_this(3) 9 >>> square_this(“number”) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 2, in square_this TypeError: can't multiply sequence by non-int of type 'str'
>>> square_this(3) 9 >>> square_this(“number”) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 2, in square_this TypeError: can't multiply sequence by non-int of type 'str'
-‐option */ CMDERR_OPTION_AMBIGUOUS = -‐2, /* ambiguous -‐option */ CMDERR_OPTION_ARG_MISSING = -‐1, /* argument missing for -‐option */ CMDERR_UNKNOWN, /* unknown command */ CMDERR_AMBIGUOUS, /* ambiguous command */ CMDERR_ERRNO, /* get the error from errno */ CMDERR_NOT_ENOUGH_PARAMS, /* not enough parameters given */ CMDERR_NOT_CONNECTED, /* not connected to server */ CMDERR_NOT_JOINED, /* not joined to any channels in this window */ CMDERR_CHAN_NOT_FOUND, /* channel not found */ CMDERR_CHAN_NOT_SYNCED, /* channel not fully synchronized yet */ CMDERR_ILLEGAL_PROTO, /* requires different chat protocol than the active server */ CMDERR_NOT_GOOD_IDEA, /* not good idea to do, -‐yes overrides this */ CMDERR_INVALID_TIME, /* invalid time specification */ CMDERR_INVALID_CHARSET, /* invalid charset specification */ CMDERR_EVAL_MAX_RECURSE, /* eval hit recursion limit */ CMDERR_PROGRAM_NOT_FOUND /* program not found */ };
“Can’t open file, screw it” else: # We can do this only if the exception # was not raised. If read() raises an # IOError, we can handle it differently contents = file.read() else
calls functions in try_this() except (ValueError, TypeError): handle_that_exception() finally: clean_up_step() def my_function(): with try_this(): # this is the context do_something() do_something_else()