On Oct 27, 1:16 am, Frank Millman <[EMAIL PROTECTED]> wrote:
> On Oct 27, 8:02 am, Frank Millman <[EMAIL PROTECTED]> wrote:
>
> > > This should work -
>
> > > egt = dict([i for i in d.items() if i[0].startswith('E')])
>
> > Of course I meant record.items(), not d.items(). Sorry.
>
> > Frank
>
> On reflection, although my solution is a bit shorter than some others,
> it may not be as efficient, as it retrieves the key and value for
> *every* entry in 'record' before testing whether the key begins with
> 'E'.

That can be fixed by using record.iteritems() instead of
record.items().

> If the dictionary is large, this may be a consideration.
>
> Frank


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

Reply via email to