On 1/23/2011 1:41 PM, Scott Meup wrote:
I'm trying tolearn Python.  The documentation tells syntax, and other things
about a command.  But for too many commands, it doesn't tell what it does.
for instance, in VB the 'return' command tells the program what line to
execute after some event (usually an error). In Python it appears to return
a value.  Where does it return it to?

The return object replaces the function call in the expression that contains the function call.

Given: x = 1; j = [2,3]; def f(): return 4
the expression: x + y[1] + f()
becomes: 1 + 3 + 4

In other words, names are looked up in the appropriate namespace and replaced with the object they are associated with in that namespace. Names followed by square brackets are replaced by the result of an indexing operation. Names followed by parentheses are called and replaced by the object returned.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to