Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

return result from exec python

the_code = '''
a = 1
b = 2
return_me = a + b
'''

loc = {}
exec(the_code, globals(), loc)
return_workaround = loc['return_me']
print(return_workaround)  # 3
Comment

PREVIOUS NEXT
Code Example
Python :: if type is string python 
Python :: python code region 
Python :: install mamba conda 
Python :: python how to get project location 
Python :: python get human readable file size 
Python :: install python 3.9 linux 
Python :: python time calculation 
Python :: pytest --clrear cache 
Python :: find all nan columns pandas 
Python :: python read file delete first line 
Python :: remove help command discord py 
Python :: how to plot count on column of dataframe 
Python :: python duplicate file 
Python :: read file line by line into list 
Python :: pandas change dtype to string 
Python :: A value is trying to be set on a copy of a slice from a DataFrame. 
Python :: django bootstrap 5 
Python :: how to make a blank window open up in python 
Python :: how to sort a list by the second element in tuple python 
Python :: print upto 1 decimal place python 
Python :: how to change background color in python turtle 
Python :: How to Add a Title to Seaborn Plots 
Python :: discord.py presence 
Python :: python open new chrome tab 
Python :: pip install apache beam gcp 
Python :: update anaconda 
Python :: tesseract.exe python 
Python :: set os environment variable python 
Python :: check pip version 
Python :: python f-string format date 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =