I'm new to python but not programming in general. Checking "Dive into Python" I have found this example (which works) but I don't get the syntax.
return ";".join(["%s=%s" % (k, v) for k, v in params.items()])
Simply put, it's using variables k and v as strings for the "%s=%s" (nothing weird here) but those variables don't have any value yet. And just like that there is a for loop which iterates and assigns values to k and v. So this is what puzzles me: 1. The for loop is "returning" somehow values k and v to the previous statement (k,v). 2. Both statements (1. "%s=%s" % (k, v) and 2. for k, v in params.items()) can be in the same line with no syntax error.
I have checked the "for" syntax reference and it doesn't even hint in this direction, so I'm sure I have to check somewhere else, but don't know where.
Thank you in advance.