[Python-ideas] get() method for list and tuples

Sven R. Kunze srkunze at mail.de
Fri Mar 3 13:48:15 EST 2017


On 03.03.2017 18:06, Ethan Furman wrote:
> On 03/02/2017 12:36 PM, Sven R. Kunze wrote:
>> On 01.03.2017 06:34, Ethan Furman wrote:
>
>>> On the bright side, if enough use-cases of this type come up (pesky 
>>> try/except for a simple situation), we may be able
>>> to get Guido to reconsider PEP 463.  I certainly think PEP 463 makes 
>>> a lot more sense that adding list.get().
>>
>> It then would make sense to remove .get() on dicts.  ;-)
>>
>> and to remove parameter "default" of max().
>> and to remove parameter "default" of getattr().
>
> Backwards compatibility, and performance, says no.  ;)
>
> try/except expressions are not a silver bullet any more than 
> try/except blocks.  But they can still be very useful.

Totally true. I think both proposals have their merit.

IIRC, Guido rightfully declared that try/except expressions aren't a 
good idea. It's better to find more concrete patterns instead of it. And 
I still agree with him.


The "default parameter" pattern is such a pattern, and it's vastly used 
in the stdlib.


Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170303/f3b5f8c5/attachment.html>


More information about the Python-ideas mailing list