Issue1520327
Created on 2006-07-11 03:40 by t-milich, last changed 2006-07-11 07:01 by georg.brandl.
|
msg29132 - (view) |
Author: Milind (t-milich) |
Date: 2006-07-11 03:40 |
|
On the last step a[10] we expect 100
>>> class A(dict):
... pass
...
>>> a = A({1:2})
>>> def foo(a,b): return 100
...
>>> a.__missing__ = foo
>>> a[1]
2
>>> a.__missing__(10,20)
100
>>> a[10]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: 10
|
|
msg29133 - (view) |
Author: Georg Brandl (georg.brandl) |
Date: 2006-07-11 07:01 |
|
Logged In: YES
user_id=849994
Methods are looked up on the type, not the instance. Add
your __missing__ method to A to make it work.
|
|
| Date |
User |
Action |
Args |
| 2006-07-11 03:40:32 | t-milich | create | |
|