TypeError: unbound method

Chris Rebert clp2 at rebertia.com
Fri Jul 17 03:08:45 CEST 2009

On Thu, Jul 16, 2009 at 5:57 PM, Ronn Ross<ronn.ross at gmail.com> wrote:
> Hello all,
> Created a python file that has a class and three methods. When I jump into
> interactive mode I import like so:
> from <file> import <class>
> Now when I try to use a method from the class:
> var1 = class.method()
> It give me this error:
> TypeError: unbound method <methodname> must be called with <classname>
> instance as first argument (got int instance instead)
> I'm not sure what is going on event after consulting with google

You're trying to call an instance method on the class itself, which
doesn't make sense.
You need to first create an instance of the class to invoke the method on.

instance = TheClass(constuctor_arguments_here)
var1 = instance.method()


More information about the Python-list mailing list