new.instancemethod and new style classes

Mark McEahern mark at
Tue Jan 22 02:17:11 EST 2002

The instancemethod of the new module does not work with new style classes:

  import new

  class fooOld:pass
  class foo(object):pass

  def bar(self):
    print "foobar" = new.instancemethod(bar, None, fooOld) = new.instancemethod(bar, None, foo)

The last line generates this error:

  Traceback (most recent call last):
    File "<stdin>", line 1, in ?
  TypeError: instancemethod() argument 3 must be class, not type

Is this by design?


// mark

More information about the Python-list mailing list