The few forms you have suggested works. But as they refer to list multiple times, it need a separate assignment statement like
list = s.split('=',1)
I am think more in the line of string.ljust(). So if we have a list.ljust(length, filler), we can do something like
name, value = s.split('=',1).ljust(2,'')
I can always break it down into multiple lines. The good thing about list unpacking is its a really compact and obvious syntax.
On Sat, 22 Jan 2005 08:34:27 +0100, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
...
So more generally, is there an easy way to pad a list into length of n with filler items appended
at the end?
some variants (with varying semantics):
list = (list + n*[item])[:n]
or
list += (n - len(list)) * [item]
or (readable):
if len(list) < n: list.extend((n - len(list)) * [item])
etc.
</F>
-- http://mail.python.org/mailman/listinfo/python-list