Tim Chase <[EMAIL PROTECTED]> wrote:

>> So basically, my question is: is there a way to access a function from
>> within itself without using its name?
> 
> 
> Well, I don't know if it's the best way to do it, but the 
> following code I just threw together does the trick for me:

The original request was to do it without using the function's name, but 
you are depending on that name so your code is easy enough to break. e.g. 
change the definition of f1 to:

   def f2(func):
     "this is f1"
     s = func()
     print s
     return s
   f1 = f2
   del f2
   
and the output is:

A function docstring
A method's docstring
A class docstring
A module docstring
If you got here, there's something I missed
> c:\temp\docstring.py(18)get_doc_string()
-> return funcname
(Pdb)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to