NameError function not found

Jason Tackaberry tack at urandom.ca
Fri May 29 16:07:12 EDT 2009


On Fri, 2009-05-29 at 15:13 -0400, Cameron Pulsford wrote:
> def _determinant(m):
>    return m[0][0] * m[1][1] - m[1][0] * m[0][1]

Given that this has no self argument, I'm assuming this is not a class
method.


> def cofactor(self):
>    """Returns the cofactor of a matrix."""

Given that this does, I assume this _is_ a class method.

So are you putting _determinant() inside the class?  If so, you should
either make it method, and invoke it as self._determinant(), or bring it
outside the class into the global scope, in which case your code should
work.

Cheers,
Jason.




More information about the Python-list mailing list