default value in a list
Fredrik Lundh
fredrik at pythonware.com
Sat Jan 22 02:37:41 EST 2005
Paul McGuire wrote:
> I asked a very similar question a few weeks ago, and from the various
> suggestions, I came up with this:
>
> expand = lambda lst,default,minlen : (lst + [default]*minlen)[0:minlen]
I wouldn't trust whoever suggested that. if you want a function, use a function:
def expand(seq, default, minlen):
return (seq + [default]*minlen)[:minlen]
</F>
More information about the Python-list
mailing list