list unpack trick?

Bengt Richter bokr at
Sun Jan 23 03:22:36 EST 2005

On Sun, 23 Jan 2005 15:43:43 +1000, Nick Coghlan <ncoghlan at> wrote:

>aurora wrote:
>> 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,'')
>Py> s.split('=',1).ljust(2,'')
>Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>AttributeError: 'list' object has no attribute 'ljust'

 Python 2.4b1 (#56, Nov  3 2004, 01:47:27)
 [GCC 3.2.3 (mingw special 20030504-1)] on win32
 Type "help", "copyright", "credits" or "license" for more information.
 >>> help(''.ljust)
 Help on built-in function ljust:

     S.ljust(width[, fillchar]) -> string

     Return S left justified in a string of length width. Padding is
     done using the specified fill character (default is a space).

I should upgrade too ;-)

Bengt Richter

More information about the Python-list mailing list