On Jan 18, 8:19 am, Reckoner <recko...@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: > y=self.a > > 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 ). -- http://mail.python.org/mailman/listinfo/python-list