This commit is contained in:
Ingy döt Net 2013-04-10 16:57:12 -07:00
parent 518da4a923
commit 764da6cbbb
6144 changed files with 83610 additions and 11 deletions

View file

@ -0,0 +1,4 @@
import exceptions
class SillyError(exceptions.Exception):
def __init__(self,args=None):
self.args=args

View file

@ -0,0 +1,2 @@
class MyInvalidArgument(ValueError):
pass

View file

@ -0,0 +1,2 @@
def spam():
raise SillyError # equivalent to raise SillyError()

View file

@ -0,0 +1,2 @@
def spam():
raise SillyError, 'egg' # equivalent to raise SillyError('egg')

View file

@ -0,0 +1,2 @@
def spam():
raise SillyError('egg')

View file

@ -0,0 +1,10 @@
try:
foo()
except SillyError, se:
print se.args
bar()
else:
# no exception occurred
quux()
finally:
baz()

View file

@ -0,0 +1,10 @@
try:
foo()
except SillyError as se:
print(se.args)
bar()
else:
# no exception occurred
quux()
finally:
baz()