In <fd02ca3a-47af-4a0b-b309-56bc732ea...@googlegroups.com> TUA <kai.pet...@gmail.com> writes:
> I want to retrieve the value for a key 'ID' but only if I have a single > result and, obviously, if ID is present. > How can I do this with pythonic elegance? > Thanks for all suggestions! if len(results) == 1 and 'ID' in results: return results['ID'] else: return 'something else' -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies" -- https://mail.python.org/mailman/listinfo/python-list