It seems nice to do this

class Klass:

    def _makeLoudNoise(self, *blah):
        ...

    woof = _makeLoudNoise


One probably wants the above to work as if you'd instead defined woof
in the more verbose form as follows:

    def woof(self, *blah): return self._makeLoudNoise(self, *blah)

It doesn't, though.  Two problems:

1. In derived classes, inheritance doesn't work right:

>>> class A:
...  def foo(s):print 'foo'
...  bar = foo
...
>>> a = A()
>>> a.bar()
foo
>>> class B(A):
...  def foo(s):print 'moo'
...
>>> b = B()
>>> b.bar()
foo
>>>

2. At least in 2.3 (and 2.4, AFAIK), you can't pickle classes that do
   this.


John
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to