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

Abe Dillon abedillon at gmail.com
Wed Mar 1 14:13:44 EST 2017


Barry, you're taking the metaphor too far. Duct typing is about presenting
a certain interface. If your function takes an object that has a get(key,
default) method, the rest doesn't matter. That's the only way in which the
object needs to resemble a duck in your function.

I'd like to +1 this proposal. It should be trivial to implement. It won't
break backward compatibility. It's intuitive. I can think of several places
I would use it. I can't think of a good reason not to include it.

On Wed, Mar 1, 2017 at 12:06 PM, Barry <barry at barrys-emacs.org> wrote:

>
> > On 1 Mar 2017, at 01:26, Michel Desmoulin <desmoulinmichel at gmail.com>
> wrote:
> >
> > - you can iterate on both
> Maybe, bit do you want the keys, values or (key, value) items? Keys being
> the deafult.
> > - you can index both
> Maybe as you cannot in the general case know the index. Need keys().
> > - you can size both
> Yes
>
> I think this duck cannot swim or quack.
>
> Barry
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170301/fc691f0f/attachment-0001.html>


More information about the Python-ideas mailing list