Re: Loading classes from multiple Python files

From: Brett Viren <bv_at_bnl.gov>
Date: Mon, 14 Mar 2011 12:00:08 -0400


Marius Bjørnstad <paul.bjoernstad_at_hep.manchester.ac.uk> writes:

> classA.py:
> class A:
> def hop():
> print "hop"
>
> classB.py:
> class B:
> def duck():
> print "quack"

You need to define the methods to take "self" as their first argument. You can run your example in plain Python to see it isn't liked there either.

But, besides that, the error you get is confusing. It seems to hint at some problem in TPython.

FWIW, on 5.26/e I get a different error with your example:

root [3] a.hop()
TypeError: hop() takes no arguments (1 given) (class A::hop)528252224

Redefining the methods to take the usual "self" as first argument removes my error.

-Brett.

Received on Mon Mar 14 2011 - 17:00:19 CET

This archive was generated by hypermail 2.2.0 : Mon Mar 14 2011 - 17:50:01 CET