simple question on dictionary usage

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Sat Oct 27 08:58:31 EDT 2007


On Sat, 27 Oct 2007 05:23:30 -0700, bearophileHUGS wrote:

> My take too :-)
> 
> dict(item for item in record.iteritems() if item[0][0] == 'E')

``s.startswith('E')`` is a little safer than ``s[0] == 'E'`` as the former
returns `False` if `s` is empty while the latter raises an `IndexError`.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list