combinations of variable length nested lists

Terry Reedy tjreedy at home.com
Tue Aug 7 19:26:03 EDT 2001


"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