[Tutor] How to determine which function code is being called from

Emile van Sebille emile at fenx.com
Thu Mar 6 18:33:52 CET 2014


While there are ways of getting at the caller using introspection, there 
are no reliable ways of doing so and you would do well to rethink the 
need and take an alternate course such as passing a parameter in.

Suppose the following:

funcC=funcB

what would you want to see?

Emile


On 3/6/2014 9:00 AM, Jignesh Sutar wrote:
> Hi I'm trying to exclude a certain line of code if the function is
> called by another function, see illustration below:
>
>
> def funcA():
>      print "running from funcA" # print only if running from funcA
>      print "running from funcA or funcB" #print when running from either
> function
>      print "running from funcB" # print only when running from funcB
>
> def funcB():
>      funcA()
>
> funcB()
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>




More information about the Tutor mailing list