On 28/02/2017 11:54, Michel Desmoulin wrote:
dict.get() is a very useful method, but for lists and tuples, we need to
rely on try/except instead.

Can we get list.get and tuple.get as well?
If PEP 463 "Exception-catching expressions" were accepted and implemented, we wouldn't need any of them:
    val = myDict[k] except KeyError: default
    val = myList[n] except IndexError: default
Rob Cliffe

Also, for list, a list.setdefault like the dict.setdefault would be logical.
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/


_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to