I have an issue with this mini game that i made which i am trying to add to a server.
I am trying to print a function from an instance of a Character but i'm not sure how to pass the proper function in. This is what i have:
class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler):
Class Character():
name = ""
age = 0
Class Human(Character):
locationX = 0
locationY = 0
def help(self):
self.request.send("Q to Quit")
class Boy(Character, Human):
def __init__(self, name):
self.name = name
age = 10
def handle(self):
p1 = self.Boy("Jim")
self.request.send(":")
command = self.request.recv(1024).strip()
if command == "help":
p1.help()
My error is:
File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
self.handle()
File "rpg.py", line 281, in handle
p1.help()
File "rpg.py", line 23, in help
self.request.send("Q to Quit")
AttributeError: Boy instance has no attribute 'request'
Can someone explain why this is wrong?