Change repr() of a new-style class to say <class 'ClassName'> rather

than <type 'ClassName'>.  Exception: if it's a built-in type or an
extension type, continue to call it <type 'ClassName>.  Call me a
wimp, but I don't want to break more user code than necessary.
This commit is contained in:
Guido van Rossum 2001-09-25 03:56:29 +00:00
parent 5c294fb0e6
commit a4cb78874c
3 changed files with 15 additions and 8 deletions

View file

@ -37,16 +37,16 @@ test_1 = """
Here's the new type at work:
>>> print defaultdict # show our type
<type 'test.test_descrtut.defaultdict'>
<class 'test.test_descrtut.defaultdict'>
>>> print type(defaultdict) # its metatype
<type 'type'>
>>> a = defaultdict(default=0.0) # create an instance
>>> print a # show the instance
{}
>>> print type(a) # show its type
<type 'test.test_descrtut.defaultdict'>
<class 'test.test_descrtut.defaultdict'>
>>> print a.__class__ # show its class
<type 'test.test_descrtut.defaultdict'>
<class 'test.test_descrtut.defaultdict'>
>>> print type(a) is a.__class__ # its type is its class
1
>>> a[1] = 3.25 # modify the instance