I'm new here, so if this isn't the right place for this, just let me know and I'll move :)

So I'm just learning python, and reading the tutorial
python tutorial
and I don't really get this part. The first (seq = 0,1,2...,8) is fine, but then how does map know to use seq,seq as x,y. It seems as though add is written again as a variable, but it is used as a function. I've never seen this without brackets {add() or add(seq,seq)}. Also, does map always take each successive argument as the argument in its included function (in this example, does map always take the first seq as add's x, and the second seq as add's y?)

>>> seq = range(8)
>>> def add(x, y): return x+y
...
>>> map(add, seq, seq)
[0, 2, 4, 6, 8, 10, 12, 14]

Thanks in advance
-Brandon

add is a variable which value is a function. In the same way, if you write z = 0.0 , then z is a variable which value is a float. The difference is that add has the special property that its "callable" with the syntax add(x, y) . You can check this

>>> callable(add)
True

Try typing

>>> help(map)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.