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

Sven R. Kunze srkunze at mail.de
Fri Mar 3 15:21:43 EST 2017


On 03.03.2017 21:09, Chris Barker wrote:
> On Fri, Mar 3, 2017 at 12:02 PM, Sven R. Kunze <srkunze at mail.de 
> <mailto:srkunze at mail.de>> wrote:
>
>>     For me to think (list/tuple).get() was needed would be if lots of
>>     folk either cast their lists to dicts or made their own list-dict
>>     class to solve that problem.
>
>     The easier solution would be to provide list.get ;-)
>
>
> Exactly -- I think that was the point -- if there is a lot of custom 
> code out there essentially adding a get() to a list -- then that would 
> indicate that is is broadly useful.
>
> For my part, I think casting a list to a dict is often the RIGHT way 
> to address these issues.

You can't be serious about this. Especially because it would negate your 
response to Ed "conditional on a len() call is the way to go". Now you 
tell people to use "convert to dict".


For my part, __getitem__ is the technical argument for this proposal.
My experience and those of other contributors to this thread make for 
the "broadly useful" argument.


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


More information about the Python-ideas mailing list