In <[email protected]> TUA
<[email protected]> 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
[email protected] B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
--
https://mail.python.org/mailman/listinfo/python-list