Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1030735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:44:51+00:00 2026-05-16T12:44:51+00:00

So this Python problem has been giving me problems since I’ve tried refactoring the

  • 0

So this Python problem has been giving me problems since I’ve tried refactoring the code into different files. I have a file called object.py and in it, the related code is:

class Object:
#this is a generic object: the player, a monster, an item, the stairs...
#it's always represented by a character on screen.
def __init__(self, x, y, char, color):
    self.x = x
    self.y = y
    self.char = char
    self.color = color

def move(self, dx, dy):
    #move by the given amount, if the destination is not blocked
    #if not map[self.x + dx][self.y + dy].blocked:
        self.x += dx
        self.y += dy

Now, when I try to compile this file specifically I get this error:

TypeError: unbound method __init__() must be called with Object instance as first argument (got int instance instead)

The code that is attempting to call this is:

player = object_info.Object.__init__(BurglaryConstants.SCREEN_WIDTH/2, BurglaryConstants.SCREEN_HEIGHT/2, '@', libtcod.white)

Which causes this error when compiling:

AttributeError: 'module' object has no attribute 'Object'

So what the heck is going on with all this and how should I be refactoring this? Also I assume having a class called Object isn’t a very good coding practice, correct?

Thanks for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:44:52+00:00Added an answer on May 16, 2026 at 12:44 pm

    Update

    You are defining Object in a file called object.py. And yet the client refers to object_info.Object. Is this a typo?

    Also I assume having a class called Object isn’t a very good coding practice, correct?

    Correct. Rename your class to something else, say GenericObject or GenericBase. Also don’t use the module name object.py. Change it appropriately.

    Also

    You are constructing an instance of Object but the way you are doing it is wrong. Try this:

    player = object_info.Object(BurglaryConstants.SCREEN_WIDTH/2, BurglaryConstants.SCREEN_HEIGHT/2, '@', libtcod.white)
    

    This chapter from Dive Into Python should prove useful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This problem probably has been discussed, but this one is slightly different. I'm using
I'm trying to rewrite some javascript code into Python. Which brings some problems since
This is the problem I have to figure out: A message has been encryption
This problem has been getting at me for a while now. Is there an
Apologies if this kind of thing has been answered elsewhere. I am using Python
First, I'll admit this is homework but it has been around six years since
This is not a unique problem that has not been there in the past,
This problem has been bugging me for the last week or so and now
Update : my problem has been solved, I updated the code source in my
I'm pretty new to Python and Scrapy and this site has been an invaluable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.