function argument dependent on another function argument?

Reckoner reckoner at gmail.com
Sun Jan 18 15:19:03 CET 2009


I  would like to do:

def foo(self,x,y=self.a)

where the default value for y=self.a. Since this is not possible, I
wind up doing


def foo(self,x,y=None)
  if not y:
    y=self.a

but that seems kind of clumsy.

Is there a better way to do this?

Thanks in advance



More information about the Python-list mailing list