method in the definiton of a methond

Gonçalo Rodrigues op73418 at mail.telepac.pt
Wed Oct 29 07:08:43 EST 2003


On 29 Oct 2003 12:22:11 +0100, Zunbeltz Izaola
<zunbeltz at wm.lc.ehu.es.XXX> wrote:

[text snipped]

>
>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
>

The traceback tells it all: self is not defined. self is *local* to
the Move method itself. You can't access it from the outside which is
what you are trying to do, by putting it in the args list for Move.

The following should work

def Move(self,handle = None):
    if handle is None:
        handle = self.GetNewHandler()
    etc,...

With my best regards,
G. Rodrigues




More information about the Python-list mailing list