Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do you print an attribute of a subclass?
    primarykey
    data
    text
    <p>I am making a text based game and this is the file I am using to establishing the attributes of the rooms. Whenever I try to test this file out by printing the room description of room3 (print Room3.desc) I receive the error: AttributeError: type object 'Room3' has no attribute 'desc'</p> <pre><code> class Room: def __init__(self, x, y, desc): self.x=x self.y=y self.desc=desc class Room1(Room): def __init__(self, x, y, desc): super(Room1, self).__init__() self.x=0 self.y=0 self.desc=""" A Metal Hallway This place is dimly lit and cool ---------------------------------------------------- You stand in the middle of an intersection in a metal room. There are blue glowing lamps lighting this area up. There is a sign on the wall. ---------------------------------------------------- Obvious exits:East, North""" class Room2(Room): def __init__(self, x, y, desc): super(Room2, self).__init__() self.x=1 self.y=0 self.desc=""" Thacker's Main Control Room This place is well lit and cool ---------------------------------------------------- There are multiple panels throughout with a variety of levers and buttons. People stand in uniforms infront of computers, which are scattered throughout the room. There is a glass window here revealing space. Thacker is sitting here in the back of the room in a large chair. ---------------------------------------------------- Obvious exits:West""" class Room3(Room): def __init__(self, x, y, desc): super(Room3, self).__init__() self.x=0 self.y=1 self.desc== """ Large Hanger Bay This place is well lit and cool ---------------------------------------------------- There are a variety of mobile suits here ---------------------------------------------------- Obvious exits:South""" print("%s" % Room3.desc) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload