Alex Martelli wrote: >> or (readable): >> >> if len(list) < n: >> list.extend((n - len(list)) * [item]) > > I find it just as readable without the redundant if guard -- just: > > alist.extend((n - len(alist)) * [item])
the guard makes it obvious what's going on, also for a reader that doesn't know exactly how "*" behaves for negative counts. once you've seen the "compare length to limit" and "extend", you don't have to parse the rest of the statement. </F> -- http://mail.python.org/mailman/listinfo/python-list