[Python-ideas] Adding __getter__ to compliment __iter__.
Joshua Landau
joshua at landau.ws
Thu Jul 18 10:56:32 CEST 2013
On 18 July 2013 07:12, Ron Adam <ron3200 at gmail.com> wrote:
>
> def extend_items(A, B):
> """ Add the content of the sub_items in B to A. """
> # A must be mutable for this function to work.
> g = A.getter() # g is an input interface to "A"
> for sub_list in B:
> g.isend(sub_list) # inserts the contents of sub_list into A
1) Say that A is a tuple -- how do you get the "aggregate" tuple out
from this at the end?
2) Personally, I just don't see enough of a use-case to want this. Our
standard "universal duck-types" includes "+" which does the same thing
for most containers.
3) It needs better names.
4) Passing in a dictionary is odd, because iter(dictionary) iterates
over keys; If you're passing in an iterable (hence "i"send) that
wouldn't work great. It just seems inconsistent in a way.
5) Chain works fine most of the time I could imagine wanting this.
More information about the Python-ideas
mailing list