tags:

views:

67

answers:

1

hello guys

for example i have def Hello(): and here is the code

def Hello():
 F = 'Y'
 if F == 'Y':
   #here i want get out of the Hello() to Hey()! by how!
+1  A: 

To exit the 'Hello' function:

def Hello():
 F = 'Y'
 if F == 'Y':
   return

You can use 'return' to exit a function before the end (though there is a school of thought that frowns on this, as it makes it slightly harder to form a solid picture of the execution flow).

This will go on to the 'Hey' function if you called it with e.g.:

Hello()
Hey()

Or, to 'jump' to the 'Hey' function, use:

def Hello():
 F = 'Y'
 if F == 'Y':
   Hey()

...but this means the call stack will still contain the data for the 'Hello' function - so when you return from the 'Hey' function, you will be returning to within the 'Hello' function, and then out of that.

sje397