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

Andre Roberge andre.roberge at gmail.com
Thu Mar 2 12:23:59 CET 2006


On 3/2/06, Ben Vinger <benvinger at googlemail.com> wrote:
>
> Hello
>
> I want myfunction in the pseudocode below return something different if it
> was called from indexfunction.
>

How about adding a parameter to myfunction itself:

def indexfunction():
     blah
     myfunction(fromindexfunction=True)

def myfunction(fromindexfunction=False):
    x = 'whatever'
    if fromindexfunction:
       return x
    else:
       return <header> + x + <footer>

André


More information about the Tutor mailing list