A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/338112.html below:

which is more 'pythonic' / 'better' ?

which is more 'pythonic' / 'better' ? 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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4