@@ -39,16 +39,16 @@ def merge(self, other):
39
39
Here's the new type at work:
40
40
41
41
>>> print(defaultdict) # show our type
42
- <class 'test.test_descrtut .defaultdict'>
42
+ <class '%(modname)s .defaultdict'>
43
43
>>> print(type(defaultdict)) # its metatype
44
44
<class 'type'>
45
45
>>> a = defaultdict(default=0.0) # create an instance
46
46
>>> print(a) # show the instance
47
47
{}
48
48
>>> print(type(a)) # show its type
49
- <class 'test.test_descrtut .defaultdict'>
49
+ <class '%(modname)s .defaultdict'>
50
50
>>> print(a.__class__) # show its class
51
- <class 'test.test_descrtut .defaultdict'>
51
+ <class '%(modname)s .defaultdict'>
52
52
>>> print(type(a) is a.__class__) # its type is its class
53
53
True
54
54
>>> a[1] = 3.25 # modify the instance
@@ -99,7 +99,7 @@ def merge(self, other):
99
99
>>> print(sortdict(a.__dict__))
100
100
{'default': -1000, 'x1': 100, 'x2': 200}
101
101
>>>
102
- """
102
+ """ % { 'modname' : __name__ }
103
103
104
104
class defaultdict2 (dict ):
105
105
__slots__ = ['default' ]
@@ -264,19 +264,19 @@ def merge(self, other):
264
264
... print("classmethod", cls, y)
265
265
266
266
>>> C.foo(1)
267
- classmethod <class 'test.test_descrtut .C'> 1
267
+ classmethod <class '%(modname)s .C'> 1
268
268
>>> c = C()
269
269
>>> c.foo(1)
270
- classmethod <class 'test.test_descrtut .C'> 1
270
+ classmethod <class '%(modname)s .C'> 1
271
271
272
272
>>> class D(C):
273
273
... pass
274
274
275
275
>>> D.foo(1)
276
- classmethod <class 'test.test_descrtut .D'> 1
276
+ classmethod <class '%(modname)s .D'> 1
277
277
>>> d = D()
278
278
>>> d.foo(1)
279
- classmethod <class 'test.test_descrtut .D'> 1
279
+ classmethod <class '%(modname)s .D'> 1
280
280
281
281
This prints "classmethod __main__.D 1" both times; in other words, the
282
282
class passed as the first argument of foo() is the class involved in the
@@ -292,18 +292,18 @@ class passed as the first argument of foo() is the class involved in the
292
292
293
293
>>> E.foo(1)
294
294
E.foo() called
295
- classmethod <class 'test.test_descrtut .C'> 1
295
+ classmethod <class '%(modname)s .C'> 1
296
296
>>> e = E()
297
297
>>> e.foo(1)
298
298
E.foo() called
299
- classmethod <class 'test.test_descrtut .C'> 1
299
+ classmethod <class '%(modname)s .C'> 1
300
300
301
301
In this example, the call to C.foo() from E.foo() will see class C as its
302
302
first argument, not class E. This is to be expected, since the call
303
303
specifies the class C. But it stresses the difference between these class
304
304
methods and methods defined in metaclasses (where an upcall to a metamethod
305
305
would pass the target class as an explicit first argument).
306
- """
306
+ """ % { 'modname' : __name__ }
307
307
308
308
test_5 = """
309
309
0 commit comments