runtime code loading
Jp Calderone
exarkun at mudprovider.com
Wed Mar 1 13:51:07 EST 2000
(First, I'm a realtive newbie to Python, so if this is dumb, please excuse
me) I've got the following code and I can't figure out why it freezes at
the marked line:
def connectionMade(self, sock, addr):
print 'Getting pObj...',
pObj = self.bootstrapObjects['Player']
print 'Done\nGetting lObj...',
lObj = self.bootstrapObjects['LoginParser']
print 'Done\nCreating player...'
self.connections[addr] = pObj(lObj, sock, addr) # Freezes here
print 'Done'
pObj and lObj are loaded with this code:
def load(name):
infile = open('../lib/code/' + name, 'r')
source = infile.readlines()
result = compile(string.join(source, '\n'), '../lib/code/' + name,
'single'
return result
and the code files contain:"
class Player:
socket = None
address = None
def __init__(self, socket, addr):
print 'Player init'
self.socket = socket
self.address = addr
def hasData(self):
return self.socket.ready()
def parse(self):
if not self.hasData():
return
else:
pass
class LoginParser:
state = -1
def __init__(self):
self.state = 0
Anything obvious that I'm doing wrong (or am I approhacing this from
completely the wrong angle?)
Thanks in advance
More information about the Python-list
mailing list