Re: a word about 'convenience'
from
Rob Miller
on Dec 19, 2007 03:49 PM
Paul Winkler wrote:
> Hi Rob, I mostly agree strongly with you, but for the sake of the
> non-python experts in our midst, I can't resist pointing out that
> this suggestion:
>
>> def member_project_brains(self, member=self.loggedinmember):
>> ### identical to 'project_brains_for' above
>
> ... doesn't work. You'll get a NameError at class definition time,
> because default args need to be resolvable then, and
> self.loggedinmember doesn't make sense there.
right, thanks for the catch.
>
> The usual idiom works:
>
> def member_project_brains(self, member=None):
> if member is None:
> member = self.loggedinmember
> ...
>
-r