@@ -40,16 +40,16 @@ def merge(self, other):
40
40
Here's the new type at work:
41
41
42
42
>>> print(defaultdict) # show our type
43
- <class 'test.test_descrtut .defaultdict'>
43
+ <class '%(modname)s .defaultdict'>
44
44
>>> print(type(defaultdict)) # its metatype
45
45
<class 'type'>
46
46
>>> a = defaultdict(default=0.0) # create an instance
47
47
>>> print(a) # show the instance
48
48
{}
49
49
>>> print(type(a)) # show its type
50
- <class 'test.test_descrtut .defaultdict'>
50
+ <class '%(modname)s .defaultdict'>
51
51
>>> print(a.__class__) # show its class
52
- <class 'test.test_descrtut .defaultdict'>
52
+ <class '%(modname)s .defaultdict'>
53
53
>>> print(type(a) is a.__class__) # its type is its class
54
54
True
55
55
>>> a[1] = 3.25 # modify the instance
@@ -100,7 +100,7 @@ def merge(self, other):
100
100
>>> print(sortdict(a.__dict__))
101
101
{'default': -1000, 'x1': 100, 'x2': 200}
102
102
>>>
103
- """
103
+ """ % { 'modname' : __name__ }
104
104
105
105
class defaultdict2 (dict ):
106
106
__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