[Tutor] Where to put small auxiliary function
Jose Amoreira
ljmamoreira at gmail.com
Fri Jul 20 13:20:07 CEST 2012
Hi Mark,
Thanks.
> [SNIP]
>> Let me give an example:
>>
>> def is_odd(k):
>> if k % 2 == 0:
>> return False
>> else:
>> return True
>
>
> I'll point out before anyone else does that you can write this function as a
> one line return. I'll leave you to work out how. Personally I prefer the
> longer version but each to their own.
>
OK, but if I wrote it as an one-liner, then it wouldn't be much use as
an example for my question...
>[SNIP]
> Don't put it in the class. It's a general purpose function that can be used
> anywhere so keep it at the module level.
>
OK, thanks. That was the kind of advice I was hoping for.
Ze
More information about the Tutor
mailing list