Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python get previous method name

import inspect
# functions
def whoami():
    return inspect.stack()[1][3]
def whosdaddy():
    return inspect.stack()[2][3]
def foo():
    print "hello, I'm %s, daddy is %s" % (whoami(), whosdaddy())
    bar()
def bar():
    print "hello, I'm %s, daddy is %s" % (whoami(), whosdaddy())
johny = bar
# call them!
foo()
bar()
johny()
Comment

PREVIOUS NEXT
Code Example
Python :: godot remove node from group 
Python :: python elementTree tostring write() argument must be str, not bytes 
Python :: how to create a numpy array linspace in python 
Python :: getch backspace pytohn 
Python :: raspberry pi python 
Python :: run a shell script from python 
Python :: easy python gui 
Python :: msg91 python 
Python :: h2o dataframe columns drop 
Python :: add last item of array at the first index of the array python 
Python :: python typewriter effect 
Python :: python find cells with na 
Python :: gui python 
Python :: python order list by multiple index 
Python :: last element of python list 
Python :: numpy sort multidimensional array 
Python :: searching for best k values in knn 
Python :: tkinter standard dialogs message 
Python :: python plot n numbers from normal distribution 
Python :: python django adding category 
Python :: def total_missing(df,column_name) 
Python :: python system performance 
Python :: python list of dict change dicts id by position in list when moved 
Python :: Iterate through string in python using for loop 
Python :: django pre_save get old instance 
Python :: open python file with read write permissions 
Python :: The MEDIA_URL setting must end with a slash. 
Python :: python greater than dunder 
Python :: python dict add item 
Python :: pandas trim string of all cells 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =