7

http://code.google.com/p/python-hidden-markov/source/browse/trunk/Markov.py

Contains a class HMM, which inherits from BayesianModel, which is a new-style class. Each has a __call__ method. HMM's __call__ method is meant to invoke BayesianModel's at line 227:

return super(HMM,self)(PriorProbs)

However, this fails with an exception

super(HMM,self)

is not callable.

What am I doing wrong?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343

1 Answers1

7

You need to invoke the __call__ method itself, explicitly:

return super(HMM, self).__call__(PriorProbs)

This applies to any hook that needs to call the overridden method on the superclass.

super() returns a proxy object, with a .__getattribute__() method that searches the super-class hierarchy for the attribute you are searching for. This proxy itself is not callable; it has no __call__ method of it's own. Only when you explicitly look up the __call__ method as an attribute of that proxy can python find the right implementation for you.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343