sync with Atlas repo

This commit is contained in:
Luciano Ramalho
2014-11-19 17:10:02 -02:00
parent b3e36a2a41
commit 2f495627fb
12 changed files with 183 additions and 112 deletions

View File

@@ -0,0 +1,31 @@
====================================
Subclassing built-in caveats
====================================
::
>>> class D1(dict):
... def __getitem__(self, key):
... return 42
...
>>> d1 = D1(a='foo')
>>> d1
{'a': 'foo'}
>>> d1['a']
42
>>> d1.get('a')
'foo'
::
>>> class D2(dict):
... def get(self, key):
... return 42
...
>>> d2 = D2(a='foo')
>>> d2
{'a': 'foo'}
>>> d2['a']
'foo'
>>> d2.get('a')
42