combinations of variable length nested lists

Mark Robinson m.1.robinson at herts.ac.uk
Wed Aug 8 03:32:26 EDT 2001


Thanks Terry, I was thinking that was nasty. It's little things like 
that, that can save you hours of heartache

Terry Reedy wrote:

> "Mark Robinson" <m.1.robinson at herts.ac.uk> wrote in message
> news:mailman.997195091.27673.python-list at python.org...
> 
>> def comb(list, *pos):
>>     if not pos:
>>        pos = 0
>>    else:
>>        pos = pos[0]
> 
> 
> Slightly more idiomatic:
> 
> def comb(lists, pos=None):
>     if pos == None:
>        pos = 0
> 
> Masking a builtin function by reusing its name leads to trouble when
> you later try to use that builtin.  I try to avoid it.  Some like
> living dangerously.  Your choice.
> 
> Terry J. Reedy




More information about the Python-list mailing list