Why Don't Return?

Terry Reedy tjreedy at udel.edu
Mon Dec 3 17:58:07 EST 2007


"Victor Subervi" <victorsubervi at gmail.com> wrote in message 
news:4dc0cfea0712031205t1a6bb511vd8744015d6ff2660 at mail.gmail.com...
| def a():
|  b()

Here is the error: should be
   c = b()

|  print c
|
| def b():
|  c = "Hi"
|  return c
|
| if __name__ == "__main__":
|  a()
|
| then run a(). Throws error about c not being defined. How do I return c 
from
| b?

You did, but you did not 'catch' it within a().  See above for change.

tjr







More information about the Python-list mailing list