which is more 'pythonic' / 'better' ?
Will McGugan
news at NOwillmcguganSPAM.com
Mon Sep 12 09:37:31 EDT 2005
Pierre Barbier de Reuille wrote:
>>
>>I would actualy use the following for this particular case..
>>
>>text = line[n:n+1] or 'nothing'
>
>
> ... and you would get either a list of one element or a string ...
> I think you wanted to write :
>
> text = (line[n:n+1] or ['nothing'])[0]
I was assuming that 'line' would be a string, not a list. Seems more
likely give the name and context.
Will McGugan
--
http://www.kelpiesoft.com
More information about the Python-list
mailing list