method = Klass.othermethod considered PITA
Leif K-Brooks
eurleif at ecritters.biz
Sat Jun 4 19:37:21 EDT 2005
John J. Lee wrote:
> class Klass:
>
> def _makeLoudNoise(self, *blah):
> ...
>
> woof = _makeLoudNoise
>
> [...]
>
> At least in 2.3 (and 2.4, AFAIK), you can't pickle classes that do
> this.
Works for me:
Python 2.3.5 (#2, May 4 2005, 08:51:39)
[GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> class Foo:
... def foo(self):
... print "Hello, world!"
... bar = foo
...
>>> pickle.dumps(Foo)
'c__main__\nFoo\np0\n.'
>>> pickle.dumps(Foo())
'(i__main__\nFoo\np0\n(dp1\nb.'
More information about the Python-list
mailing list