Go to Google Groups Home    comp.lang.python
Re: Newbie: Struggling again 'map'

Marc 'BlackJack' Rintsch <bj_...@gmx.net>

In <1180173252.906992.262...@q75g2000hsh.googlegroups.com>, mosscliffe
wrote:

> for x,y in map(None, lista, listb):  #  Also fine - extends as
> expected
>     print "MAP:", x, "<<x  y>>", y

> for x,y in map("N/A", lista, listb): ########## Fails - Can not call a
> 'str'
>     print "MAP:", x, "<<x  y>>", y

> def fillwith(fillchars):
>     return fillchars

> for x,y in map(fillwith("N/A"), lista, listb): ########## Fails also -
> Can not call a 'str'
>     print "MAP:", x, "<<x  y>>", y

`map()` expects a function as first argument that will be applied to the
elements in the other the arguments which have to be iterable.  That you
can give `None` as a function and the resulting behavior is IMHO a very
ugly thing and has not much to to with the semantics expected from a
`map()` function.  The `None` is not the default fill value but a
placeholder for the identity function.

Ciao,
        Marc 'BlackJack' Rintsch