* 'struct-like' list *

Bengt Richter bokr at oz.net
Fri Feb 10 17:59:46 EST 2006


On Tue, 07 Feb 2006 18:10:05 GMT, bokr at oz.net (Bengt Richter) wrote:
[...]
>----< ernesto.py >---------------------------------------------------------
[...]
Just noticed:
>        substrings = line.split()
>        if substrings and isinstance(substrings, list) and substrings[0] == 'Name:':
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--not needed

str.split always returns a list, even if it's length 1, so that was harmless but should be

         if substrings and substrings[0] == 'Name:':

(the first term is needed because ''.split() => [], to avoid [][0])
Sorry.

Regards,
Bengt Richter



More information about the Python-list mailing list