At 18:09 08.06.2003 +0200, Gerrit Holl wrote: >Hi, > >Alex Martelli wrote: > > > if issubclass(typ, dict) and type(typ.__repr__) is > type(dict.__repr__): > > > # do stuff > > > > Aren't the calls to type() here wrong? It seems to me that what you want > > to check is just whether typ.__repr__ is dict.__repr__, not if the > types of > > the two bound methods are the same. > >I was confused: I thought methods were dynamically created, but that is >only true for bound methods, not for unbound methods. typ.__repr__ is >dict.__repr__ is correct indeed. > >yours, >Gerrit. no it's true also for unbound methods but dict.__repr__ isn't either: >>> class C(object): ... def f(self): pass ... >>> C.f is C.f 0 >>> C.f <unbound method C.f> >>> dict.__repr__ <slot wrapper '__repr__' of 'dict' objects> >>> the problem is that the nature of dict.__repr__ is kind of an implementation detail. regards.
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