-2

I have a script which monitor a directory and call a function with certain arguments. And in this script a open file.log to explain what happened each time there is a new file in the monitored directory.

This is the prototype of my function :

def and_now_my_watch_begin(dir_to_watch, function_to_call, *args_for_function):

I would like to know if there was any way to get function's name like a function.name.to_str() or something like this ?

2
  • You know, there is a search function. Commented Dec 10, 2015 at 10:32
  • Ctrl-F? Up-up-down-down-left-right-left-right B-A-B-A? //*[@id="search"]/input ?? Commented Oct 10, 2017 at 18:29

2 Answers 2

3

Sure, simply look into __name__:

>>> def foo(): pass
... 
>>> foo.__name__
'foo'
Sign up to request clarification or add additional context in comments.

Comments

0

You can use the __name__ attribute of the function. For example:

def function():
    return

print(function.__name__)

This will print:

'function'

1 Comment

Whoever downvoted my answer, please explain why so I can know where I have not succeeded in answering.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.