function argument dependent on another function argument?
castironpi at gmail.com
Sun Jan 18 15:41:31 CET 2009
On Jan 18, 8:19 am, Reckoner <recko... at gmail.com> wrote:
> 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:
> but that seems kind of clumsy.
> Is there a better way to do this?
> Thanks in advance
No. The only alternative is really niche and probably not what you
want. You'd use a decorator (which I don't have, btw):
@defval( y= selfattrget( 'a' ) )
def foo( self, x, y ).
More information about the Python-list