Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I am using a python file. I want to call another python code. Is there any way by which i can return data from 2nd python code to calling python code. Anything like function returns value to calling function.
return
I must admit I don't see the problem:
test1.py:
test1.py
def myfunc(): return "spam!"
test2.py:
test2.py
import test1 print(test1.myfunc())
Output when running test2.py:
spam!
Add a comment
Get everything into classes and functions and read a lot about importing modules
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
returna value), so which part exactly are you having problems with?