On Oct 27, 8:58 am, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> 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`.

A string slice is safe and faster though: if s[:1] == 'E'.

George

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to