On Fri, Dec 06, 2019 at 04:38:10PM +1100, Steven D'Aprano wrote: > On Thu, Dec 05, 2019 at 05:40:05PM -0400, Juancarlo AƱez wrote: > > I just found this code: > > > > def get_product_item(jsonld_items): > > for item in jsonld_items: > > if item['@type'] == 'Product': > > return item > > else: > > return {}
[...] > The name says it returns an item, but the default is to return an empty > dict, which seems like an unusual choice for the "default product where > no product is specified". I would have guessed None if the product is > missing. Ah, on closer inspection I get it now: the items are dicts, so if there's no item with the @type set to "Product", an empty dict is appropriate. -- Steven _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/PZWVR43OIOOM5AZOCWZINPI64CET55X2/ Code of Conduct: http://python.org/psf/codeofconduct/