4

I have 2 classes. The first is named test and goes as following:

import textbox
class test:

    a=textbox("test")
    a.run()

the second class is textbox and goes as following:

class textbox():
    def __init__(self, string):
        self.string=string
    def run(self):
        print string

i get this error

File "C:\Users\User\Desktop\edoras\gui\test.py", line 4, in test
    a=textbox("test")
TypeError: 'module' object is not callable

I use the pydev eclipse plugin

1
  • Can we assume (as @silvado does in his question) that textbox class is declared inside textbox module? Commented Jan 10, 2012 at 17:28

3 Answers 3

7

Try

a = textbox.textbox("test")

or alternatively use

from textbox import textbox
Sign up to request clarification or add additional context in comments.

2 Comments

This is only true if this assumption that the class textbox is located in the file textbox.py is true.
Yes, I was guessing so from the import statement.
1

Not sure about the error you mention, but your print statement in text box.run is wrong:

print self.string

Comments

0

You are calling directly the module textbox, which is not allowed.

Maybe it contains an omonymous function? In that case you should call

textbox.textbox('test')

(the first textbox would be the module name, and the second a function inside it)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.