1

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
1
  • Are you sure width is a method and not a property? Have you tried ins.width? Commented May 7, 2012 at 21:15

3 Answers 3

4

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
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.