TypeError: object() takes no parameters - attempting to load a .txt file into a game
Question: I've been trying to work through [How to Write a Text Adventure in
Python](http://letstalkdata.com/2014/08/how-to-write-a-text-adventure-in-
python-part-2-the-world-space/) but have run into the error `TypeError:
object() takes no parameters` on the last line of this given code when I
attempt run it in the command prompt. I tried to research what this error
means, but can't figure out how to correct it in the context of my code. What
is causing this error? I apologize if anything is unclear.

    
    
    _world = {}
    starting_position = (0, 0)
    def load_tiles():
    """Parses a file that describes the world space into the _world object"""
    with open('resources/map.txt', 'r') as f:
        rows = f.readlines()
    x_max = len(rows[0].split('\t'))
    for y in range(len(rows)):
        cols = rows[y].split('\t')
        for x in range(x_max):
            tile_name = cols[x].replace('\n', '') 
            if tile_name == 'StartingRoom':
                global starting_position
                starting_position = (x, y)
            _world[(x, y)] = None if tile_name == '' else getattr(__import__('tiles'), tile_name)(x, y)
    


Answer: # Best guess

The object called `tile_name` in your `tiles` module is a class that inherits
direct from `object` but has not overridden the `__init__()` method properly.

Show me the code in your tile.py module and that will probably show the
reason.

## More info on probable cause

New-style classes in python2 inherit from `object` (by definition). If you
call a method on your class which you haven't defined, python tries to use the
super-class's method, so in this case if you haven't defined `__init__` then
python tries to use `object.__init__`. But `object.__init__` takes no
arguments (ever), and so that's what it's complaining about.

So for example, if you write the two files below and run `python main.py` you
can recreate one way of getting this bug more simply:

main.py

    
    
    getattr(__import__('tiles'), 'Class')(1, 2)
    

tiles.py

    
    
    class Class(object):
        pass
    

## Alternative cause

Alternatively, you often get this bug if you call `super` with arguments
without thinking about what the superclass is, so this looks similar:

main.py

    
    
    getattr(__import__('tiles'), 'Class')(1, 2)
    

tiles.py

    
    
    class Class(object):
        def __init__(self, *args):
            super(Class, self).__init__(*args)
    

But you'll get a slightly different stack trace.

