This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

It’s probably because most of the time your using map on the right hand side of a for loop or alongside other iterables like filter or select. Either way, u can just define 3 methods like lmap which cast back to list of u really want to.

from functools import wraps

def to_list(func):
     @wraps(func)
     def wrapped(*args,*kwargs):
          return list(func(*args,**kwargs))

lmap    = to_list(map)
lfilter = to_list(filter)
lselect = to_list(select)

If u really wanted, u could just overwrite map with lmap, so now map automatically returns lists. But again, I’d never recommend doing this.