mardi 24 octobre 2017

Python: If-Else Statement That Depends on Calling Function

I've been thinking about this question for a while, and I can't seem to find any related questions to it, probably because I don't know the proper terminology for what I'm looking for.

Is there any condition for an if-else statement in a function that is reliant on which other function is doing the calling? Such as:

def FUNC():
    if func1 called FUNC:
        statement
    elif func2 called FUNC:
        statement

def func1():
    FUNC()

def func2():
    FUNC()

I'm not sure what purpose there would be behind doing this, but I just wanted to know if it was an available option. Thank you.

Aucun commentaire:

Enregistrer un commentaire