[Python-ideas] Make map() better

Jason H jhihn at gmx.com
Wed Sep 13 17:05:26 EDT 2017



> Sent: Wednesday, September 13, 2017 at 3:57 PM
> From: "Stefan Behnel" <stefan_ml at behnel.de>
> To: python-ideas at python.org
> Subject: Re: [Python-ideas] Make map() better
>
> Jason H schrieb am 13.09.2017 um 17:54:
> > I'm rather surprised that there isn't a Iterable class which dict and list derive from.
> > If that were added to just dict and list, I think it would cover 98% of cases, and adding Iterable would be reasonable in the remaining scenarios.
> 
> Would you then always have to inherit from that class in order to make a
> type iterable? That would be fairly annoying...
> 
> The iterable and iterator protocols are extremely simple, and that's a
> great feature.
> 
> And look, map() even works with all of them, without inheritance,
> registration, and whatnot. It's so easy!

Define easy. 

It's far easier for me to do a dir(dict) and see what I can do with it. This is what python does after all. "Does it have the interface I expect?"
Global functions like len(), min(), max(), map(), etc(), don't really tell me the full story. len(7) makes no sense. I can attempt to call a function with an invalid argument. [].len() makes more sense. Python is weird in that there are these special magical globals that operate on many things. Why is it ','.join(iterable), why isn't there join(',', iterable) At what point does a method become a global? A member? Do we take the path that everything is a global? Or should all methods be members? So far it seems arbitrary.




More information about the Python-ideas mailing list