[Tutor] How can a function know where it was called from

Noufal Ibrahim noufal at nibrahim.net.in
Thu Mar 2 12:39:39 CET 2006

On Thu, March 2, 2006 3:55 pm, Ben Vinger wrote:
> Hello
> I want myfunction in the pseudocode below return something different if it
> was called from indexfunction.

I'm new to this but maybe it would be good if you passed the appropriate
"version" of "myfunction" to indexfunction from where the original
decision of which one to use was made rather than doing it at the lower

Something like.

def myfunwithheaders(x):
  return header + x + footer

def myfunwithoutheaders(x):
  return x

def main():
   if needheaders:

def myfunction(ret):
   x = "whatever"
   return ret(x)

I'd appreciate if some of the more experienced folks on the list comment
on the general approach.

Thanks much.


More information about the Tutor mailing list