The best way to build efficiently is to understand the toolkit one is building with. However, while trying to understand the core functions of python, it occurred to me that the map function gave similar, if not the same, results as a generic generator expression.
Take the next bit of code as a simplified example. These two objects, mapped and generated, behave astoundingly similar in whatever situation you throw them.
def concatenate(string1 = "", string2 = ""):
return string1.join(" ", string2)
foo = ["One", "Two"]
bar = ["Blue", "Green"]
mapped = map(concatenate, foo, bar)
generated = (concatenate(string1 = a, string2 = b) for a, b in zip(foo, bar))
Okay, I know that it is a longer line of code, but I find it hard to believe that's all of map's reason of existence, so in my quest to understand python. What does map still do in python? Is it really just a relic of olden times, and if not, where can I best put this tool to use?