Re: How to refer to the function object itself in the function per se?

2006-03-11 Thread Kay Schluehr
Sullivan WxPyQtKinter wrote: > I am sorry but you misunderstood my idea. > What I want is a generalized method to print out the function name, or > refer to the name of a function. If I use f.__name__, I think I should > just use print "f" to save my keyboard. What I expect is using a > method, or

Re: How to refer to the function object itself in the function per se?

2006-03-11 Thread James Stroud
Sullivan WxPyQtKinter wrote: > I am sorry but you misunderstood my idea. > What I want is a generalized method to print out the function name, or > refer to the name of a function. If I use f.__name__, I think I should > just use print "f" to save my keyboard. What I expect is using a > method, or

Re: How to refer to the function object itself in the function per se?

2006-03-11 Thread James Stroud
Sullivan WxPyQtKinter wrote: If I would like to refer to the function object in order > to call it recursively, what shall I do then? I think the question is too simple. You can just refer to the function by its name. Here is an example: py> def f(start, end): ... if start >= end: ... pri

Re: How to refer to the function object itself in the function per se?

2006-03-11 Thread Sullivan WxPyQtKinter
I am sorry but you misunderstood my idea. What I want is a generalized method to print out the function name, or refer to the name of a function. If I use f.__name__, I think I should just use print "f" to save my keyboard. What I expect is using a method, or attribute, or another function to get t

Re: How to refer to the function object itself in the function per se?

2006-03-11 Thread Kay Schluehr
Sullivan WxPyQtKinter wrote: > So how > could I refer to the function object per se, in the body of the > function itself? Just use the name. def f(): print f.__name__ >>> f() f -- http://mail.python.org/mailman/listinfo/python-list

Re: How to refer to the function object itself in the function per se?

2006-03-11 Thread Duncan Booth
Sullivan WxPyQtKinter wrote: > I have Google the whole thing and find another way for alternative > implementation of getting the function's name. But all they returns are > just strings. If I would like to refer to the function object in order > to call it recursively, what shall I do then? > a

Re: How to refer to the function object itself in the function per se?

2006-03-11 Thread Sullivan WxPyQtKinter
I have Google the whole thing and find another way for alternative implementation of getting the function's name. But all they returns are just strings. If I would like to refer to the function object in order to call it recursively, what shall I do then? -- http://mail.python.org/mailman/listinf

Re: How to refer to the function object itself in the function per se?

2006-03-11 Thread Duncan Booth
Sullivan WxPyQtKinter wrote: > So how > could I refer to the function object per se, in the body of the > function itself? > > I don't believe you can easily get at the function object, but you can get at the code object which also has a name (which will be the same as the function's name unles

How to refer to the function object itself in the function per se?

2006-03-11 Thread Sullivan WxPyQtKinter
When debugging using 'print' statement, I usually want to print some important values together with the function name as the context of the values printed out. So my hope is that I could get the name of the function. Since every function object actually has a private __name__ attribute that gives