On 04/10/2012 02:04 AM, Shashank Singh wrote: > On Mon, Apr 9, 2012 at 10:49 PM, Nikhil Verma <varma.nikhi...@gmail.com>wrote: > <SNIP> >> I am trying this but its giving me a generator object. >> >> In [9]: (k for k,v in for_patient_type.iteritems() if v == 'Real') >> > Iterating over a dict gives you all the keys, not the key value pairs >
But that line does not iterate over the dict, it iterates over an iterator consisting of key/value pairs. Note he had a call to iteritems(). -- DaveA -- http://mail.python.org/mailman/listinfo/python-list