how can I import a list which is defined inside a function in python script into another python script. Please explain using an example
Using variable from another python script?
- Posted:
- 3+ months ago by Vikesh0610
- Topics:
- python, inside, script, example
Details:
Answers (1)
--otherscript.py--
vlst = ["hello","world"]
--otherfunc.py--
def Bacon_Spam(p1)
"""Spam.
Spam."""
vlst = ["Bacon","Eggs",p1,"Spam"]
return vlst
--main.py--
from otherscript import vlst
print(vlst)
from otherfunc import Bacon_Spam
vlst2 = Bacon_Spam("and")
print(vlst2)
---
Python is great.