I want to get the name of the function / method being executed

I forget it every time, so make a note.

sys._getframe().f_code.co_name

Write a simple function and give it a try.

>>> def printFuncName():
...     print sys._getframe().f_code.co_name
... 
>>> printFuncName()

printFuncName

I often use it in such situations.

from abc import abstractmethod

class SuperClass(object):

    @abstractmethod
    def implementMe():
        raise NotImplementedError( sys._getframe().f_code.co_name )

Recommended Posts

I want to get the name of the function / method being executed
I want to get the file name, line number, and function name in Python 3.4
I want to get the operation information of yahoo route
Keras I want to get the output of any layer !!
I tried to get the index of the list using the enumerate function
I want to get League of Legends data ③
I want to get League of Legends data ②
I want to customize the appearance of zabbix
I want to get League of Legends data ①
I want to use the activation function Mish
Python: I want to measure the processing time of a function neatly
I want to see the file name from DataLoader
I want to get the path of the directory where the running file is stored.
I want to grep the execution result of strace
I want to fully understand the basics of Bokeh
[Python] I tried to get the type name as a string from the type function
I want to increase the security of ssh connections
Try to get the function list of Python> os package
I tried to get the location information of Odakyu Bus
I want to move selenium for the time being [for mac]
I want to use only the normalization process of SudachiPy
I made a function to check the model of DCGAN
I want to judge the authenticity of the elements of numpy array
I want to know the features of Python and pip
I tried to fight the Local Minimum of Goldstein-Price Function
I want to know the legend of the IT technology world
I want to create a Dockerfile for the time being.
To get the name of the primitive etc. generated immediately before
[Linux] [C / C ++] How to get the return address value of a function and the function name of the caller
I want to find the intersection of a Bezier curve and a straight line (Bezier Clipping method)
I want to manually assign the training parameters of the [Pytorch] model
I want to read the html version of "OpenCV-Python Tutorials" OpenCV 3.1 version
I want to output the beginning of the next month with Python
When you want to save the result of the callback function somewhere
I want to make the second line the column name in pandas
For the time being, I want to convert files with ffmpeg !!
I want to check the position of my face with OpenCV!
I tried to summarize the frequently used implementation method of pytest-mock
Create a function to get the contents of the database in Go
I want to know the population of each country in the world.
I want to pin Spyder to the taskbar
I want to output to the console coolly
I want to handle the rhyme part1
I want to handle the rhyme part3
I want to display the progress bar
I want to clear up the question of the "__init__" method and the "self" argument of a Python class.
I want to handle the rhyme part2
I want to handle the rhyme part5
I want to handle the rhyme part4
I tried to get the batting results of Hachinai using image processing
[Note] I want to completely preprocess the data of the Titanic issue-Age version-
I don't want to admit it ... The dynamical representation of Neural Networks
[Linux] Command to get a list of commands executed in the past
(Python Selenium) I want to check the settings of the download destination of WebDriver
I measured 6 methods to get the index of the maximum value (minimum value) of the list
I want to batch convert the result of "string" .split () in Python
I want to explain the abstract class (ABCmeta) of Python in detail.
I tried to get the authentication code of Qiita API with Python.
I want to sort a list in the order of other lists
I want to express my feelings with the lyrics of Mr. Children
I want to analyze the emotions of people who want to meet and tremble