Hacker News new | ask | show | jobs
by ivanivanovich 1841 days ago
why is it broken?
1 comments

In common sense, u just need to put a function into map, right ?

x.map(fn)

In python, mapped takes some arguments that makes me confused in order and types of arguments.

Secondly, it broke my thinking process.

Inline code completion/IDE integration can have it show the parameter names or docstring inline in the editor. That helps me with map, specifically. :)

With that configured, a window pops up in Vim and says we have:

    map(func: Callable[[_T1], _S], iter1: Iterable[_T1], /) -> Iterator[_S]                                               
     ——————————————————————————————————————————————————————————————————————————————                                        
    map(func, *iterables) --> map object                                                                                  
                                                                                                                          
    Make an iterator that computes the function using arguments from                                                      
    each of the iterables.  Stops when the shortest iterable is exhausted.                                                
                                                                                                                          
    ——————————————————————————————————————————————————————————————————————————————

There are things to criticize here. Note that the type hinting (this is Python 3.8 btw) doesn't agree with the full generality of the stated function interface (the multiple iterables part).
Having a different interface doesn't mean its broken...