So this Python issue was giving me problems, as I was trying to reorganize the code into different files. I have a file called object.py and there is related code in it:
class Object:
def __init__(self, x, y, char, color):
self.x = x
self.y = y
self.char = char
self.color = color
def move(self, dx, dy):
self.x += dx
self.y += dy
Now, when I try to compile this file, I get this error:
TypeError: unbound method __init__() must be called with Object instance as first argument (got int instance instead)
Code that tries to call this:
player = object_info.Object.__init__(BurglaryConstants.SCREEN_WIDTH/2, BurglaryConstants.SCREEN_HEIGHT/2, '@', libtcod.white)
What causes this compilation error:
AttributeError: 'module' object has no attribute 'Object'
So what the hell is going on with all this and how should I reorganize it? I also assume that the class of the Object class is not a very good coding practice, right?
Thank you for your help!
source
share