method in the definiton of a methond

Zunbeltz Izaola zunbeltz at wm.lc.ehu.es.XXX
Wed Oct 29 06:22:11 EST 2003


I've a clas with following methods:

class difracsocket:
    def __init__(self,sock=None):
        self.Handle = 1
        [...]        

    def cliente(self,orden,respuesta):
        [...]

    def GetNewHandle(self):
        newhandle = self.Handle
        newhandle += 1
        if newhandle > MAXHANDLE:
            newhandle = 1
        self.Handle = newhandle
        return newhandle

    def Move(self, table, angle,handle=1):
        orden = instruccion(handle)
        respuesta = instruccion
        orden.Codigo = 6
        Comando = "mvr "
        if table == "TTH" or "tth":
            Comando += "tth "
        elif table == "TH" or "th":
            Comando += "th "
        Comando += str(angle)
        orden.Comando = Comando
        self.cliente(orden,respuesta)
        return respuesta

I what to change de definiton of Move to something like
    def Move(self, table, angle,handle=self.GetNewHandle)
        

  File "comunicacion.py", line 201, in difracsocket
    def Move(self,handle=self.GetNewHandle()):
NameError: name 'self' is not defined

Any hit? Can't i invoke methods in the definition of other methods?
Thanks in advance

Zunbeltz


-- 
Remove XXX from email: zunbeltz at wm.lc.ehu.esXXX




More information about the Python-list mailing list