[Tutor] How to determine which function code is being called from
Dave Angel
davea at davea.name
Thu Mar 6 20:14:12 CET 2014
Jignesh Sutar <jsutar at gmail.com> 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 point about making functions is to reuse code without caring
who is calling it. If the function is going to have variable
behavior, control that by passing parameters.
Or perhaps this is testing code or debugging code. In that case,
look at docs.python.org/2/library/inspect.org and look at
function inspect.getouterframes ()
Can you give a nontrivial use example, and without using recursion?
--
DaveA
More information about the Tutor
mailing list