mirror of
https://github.com/python/cpython.git
synced 2025-10-15 19:29:46 +00:00
Expanded r() function to handle class exceptions.
This commit is contained in:
parent
f488af3360
commit
6ed41a0a87
1 changed files with 6 additions and 1 deletions
|
@ -1,11 +1,16 @@
|
||||||
# Python test set -- part 5, built-in exceptions
|
# Python test set -- part 5, built-in exceptions
|
||||||
|
|
||||||
from test_support import *
|
from test_support import *
|
||||||
|
from types import ClassType
|
||||||
|
|
||||||
print '5. Built-in exceptions'
|
print '5. Built-in exceptions'
|
||||||
# XXX This is not really enough, each *operation* should be tested!
|
# XXX This is not really enough, each *operation* should be tested!
|
||||||
|
|
||||||
def r(name): print name
|
def r(thing):
|
||||||
|
if type(thing) == ClassType:
|
||||||
|
print thing.__name__
|
||||||
|
else:
|
||||||
|
print thing
|
||||||
|
|
||||||
r(AttributeError)
|
r(AttributeError)
|
||||||
import sys
|
import sys
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue