samedi 27 juin 2015

Python get variable from running script and pass to another Python script

I have a short but for me very important question:

I would like to write variables from an active python script that is already running to another python script. So I don't want something like this:

$ cat first.py second.py 
#first.py
def demo():
    some_list = []
    for i in 'string':
         some_list.append( i )
    return list

#second.py 
from first import demo

some_list = demo()
print some_list 

$python second.py
['s', 't', 'r', 'i', 'n', 'g']

I want my running script , e.g. "sent.py" to write constantly variables to some kind of "workspace", and then for example access those variables over another script, e.g. "get.py". And that without that I have to start both scripts together in a bash script.

So I am probably looking for a solution that is first passing python to bash an then to python again? I am very sorry, I am not so familiar with the terminology.

I hope it became clear what I mean, I did my best to explain it. I am kind of desperate and hope you can help. I have tried out and googled all kinds of stuff, but it just didn't work.

Aucun commentaire:

Enregistrer un commentaire