[GvR] > But your _inst_fromkeys mutates self! That issue wasn't intrinsic to the proposal. The implementation should have read: class MagicDict(dict): def newfromkeys(obj, cls, lst, value=True): "Returns a new MagicDict with the keys in lst set to value" if obj is not None: cls = obj.__class__ newobj = cls() for elem in lst: newobj[elem] = value return newobj newfromkeys = universalmethod(newfromkeys) Universal methods give the method a way to handle the two cases separately. This provides both the capability to make an instance from scratch or to copy it off an existing instance. Your example was especially compelling: a = [3,2,1] print a.sorted() print list.sorted(a) Raymond Hettinger
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4