Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to convert string to function name in python

def add(x,y):
	print('does something')
    
eval("add")(x,y)
Comment

Python How to convert a string to the name of a function?

def test():
	print("Working")


eval("test")  # function name
# or
eval("test")()  # function call
Comment

PREVIOUS NEXT
Code Example
Python :: python for loop backwards 
Python :: file to lowercase python 
Python :: check dictionary is empty or not in python 
Python :: how to get the year in python 
Python :: python find closest value in list to zero 
Python :: python remove stop words 
Python :: create np nan array 
Python :: how to find shortest string in a list python 
Python :: read tsv file column 
Python :: pyqt5 latex 
Python :: set python3.7 as default ubuntu 
Python :: google translate with python 
Python :: check pip installed packages inside virtualenv 
Python :: get index of list item in loop 
Python :: seconds add zero python 
Python :: python get filename without extension 
Python :: python negation of an statement 
Python :: python bcrypt 
Python :: how to install python libraries 
Python :: python ls 
Python :: append a line to a text file python 
Python :: show number as 3 digit python 
Python :: the month before python dateime 
Python :: random py 
Python :: sns legend outside 
Python :: pandas string does not contain 
Python :: find duplicate in dataset python 
Python :: jupyter notebook change default directory 
Python :: python read lines from text file 
Python :: python tkinter quit button 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =