On 06/04/12 09:47, Karim wrote:

If you have any idea to get the caller name inside the caller.


Its not normally very helpful since in Python the same function can have many names:

def F(x):
   return x*x

a = F
b = F
c - lambda y: F(y)

print F(1), a(2), b(3), c(4)

Now, why would knowing whether the caller used F,a or b
to call the same function object help? And what do you
do in the case of c()? Do you return 'c' or 'F'?

Maybe you could use it to tell you the context from
which they were calling? But in that case there are
usually better, more reliable, techniques
 - like examining the stackframe.

HTH,
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to