tivon
tivon

Reputation: 13

Object not callable python

Got this error while trying to get the variables out of a class. Using tkinter and a class Options

width = ins.width()
TypeError: 'int' object is not callable

Upvotes: 1

Views: 6785

Answers (3)

cobie
cobie

Reputation: 7271

the () is for only function/method calls in python. what you want is access to a property like ins.width

Upvotes: 0

Holger Just
Holger Just

Reputation: 55758

You always have to distinguish between a called method and a simple attribute access. width seems to be either a property or an ordinary instance variable, not a method. Thus you can't call it but just get (or set) it's value.

width = ins.width

Upvotes: 1

ChristopheD
ChristopheD

Reputation: 116147

width is not a method (which you can call), but an attribute (of type int).

If you re-read the error it might start to make more sense.

In short: you just need to drop the parentheses.

e.g.

width = ins.width

Upvotes: 4

Related Questions