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

2014-03-07 Thread eryksun
On Fri, Mar 7, 2014 at 6:45 AM, Danny Yoo wrote: > > Although many of the recommendations have been discouraging the stack > inspection approach, even stack inspection might be appropriate, > though it's certainly not a technique for beginners. Stack inspection is really intended for debugging or

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

2014-03-07 Thread Danny Yoo
> def funcB(runfromB): > funcA(runfromB=runfromB) > > funcB(runfromB=True) Yes, this is something that might be appropriate. But it really does depends on your context. Although many of the recommendations have been discouraging the stack inspection approach, even stack inspection might be

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

2014-03-07 Thread Jignesh Sutar
Hi All, thanks for the comments and yes I am a tad confused and a little out of my comfort zone with what I am trying to achieve here. Is this below any better way (or even worse?) of trying to achieve this. Though this doesn't actually achieve what I want it to, it may nonetheless highlight the co

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

2014-03-06 Thread Jerry Hill
On Thu, Mar 6, 2014 at 12:00 PM, 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: As other have said, this is not often a good idea. That said, it is possible to inspect the call stack to see what call

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

2014-03-06 Thread Danny Yoo
On Thu, Mar 6, 2014 at 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

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

2014-03-06 Thread Dave Angel
Jignesh Sutar Wrote in message: > > Hi I'm trying to exclude a certain line of code if the function is called by another function, see illustration below: Your code example is all confused, so perhaps you are as well. Why should any of your code in function A care who calls it? The main po

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

2014-03-06 Thread spir
On 03/06/2014 06:00 PM, 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 whe

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

2014-03-06 Thread Emile van Sebille
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