On Tue, 4 Jan 2005 10:28:03 -0800, Guido van Rossum <gvanrossum at gmail.com> wrote: >In my blog I wrote: > > Let's get rid of unbound methods. When class C defines a method f, C.f > should just return the function object, not an unbound method that > behaves almost, but not quite, the same as that function object. The > extra type checking on the first argument that unbound methods are > supposed to provide is not useful in practice (I can't remember that > it ever caught a bug in my code) and sometimes you have to work around > it; it complicates function attribute access; and the overloading of > unbound and bound methods on the same object type is confusing. Also, > the type checking offered is wrong, because it checks for subclassing > rather than for duck typing. > This would make pickling (or any serialization mechanism) of `Class.method' based on name next to impossible. Right now, with the appropriate support, this works: >>> import pickle >>> class Foo: ... def bar(self): pass ... >>> pickle.loads(pickle.dumps(Foo.bar)) <unbound method Foo.bar> >>> I don't see how it could if Foo.bar were just a function object. Jp
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