2004-05-09 15:42

Hard Python question

I am trying to do something which is, I think, pretty cool, in python.

However, I like showing things working, and I am having troubles with the last final step on what I am trying to achieve.

Since I know a few better python programmers read this...

Suppose I have this:

def fun(self,x):
        pass

class C:
        pass

C.a=fun
C.b=fun

What code should be in fun() so that it figures out if it has been called as C.a or as C.b?

I am thinking something like reading the higher step in a backtrace, but I don't know enough python to figure out how to do that.

Comments

Comments powered by Disqus

Contents © 2000-2018 Roberto Alsina