469,282 Members | 1,704 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

access variables from one Python session to another on the samemachine?

Suppose I have two different command windows going on the same
machine, each running their own Python interpreters.

Is it possible to access the variables in one of the interpreter-
sessions from the other?

It turns out I have limited control over one of the sessions (i.e.
cannot control all the code that is run from there), but complete
control over the other.

I get the feeling this has been asked before, but I'm not sure how to
pose the question in such a way that it would show up on a search.
It's confusing.

Thanks.
Jun 27 '08 #1
3 782
Reckoner wrote:
Suppose I have two different command windows going on the same
machine, each running their own Python interpreters.

Is it possible to access the variables in one of the interpreter-
sessions from the other?

It turns out I have limited control over one of the sessions (i.e.
cannot control all the code that is run from there), but complete
control over the other.

I get the feeling this has been asked before, but I'm not sure how to
pose the question in such a way that it would show up on a search.
It's confusing.

Thanks.

IMHO without "significant" access to both programs I believe the answer is no.
You would have to introduce something in the master window that would "expose"
data to the slave window. Normally this is done via: socket server, pipes,
shared database, etc.

Does the master, provide output that could be captured and used as input to the
slave? If so, you might be able to use subprocess module to make it work.

-Larry
Jun 27 '08 #2
Suppose I have two different command windows going on the same
machine, each running their own Python interpreters.

Is it possible to access the variables in one of the interpreter-
sessions from the other?

It turns out I have limited control over one of the sessions (i.e.
cannot control all the code that is run from there), but complete
control over the other.

I get the feeling this has been asked before, but I'm not sure how to
pose the question in such a way that it would show up on a search.
It's confusing.
Depending on what 'limited control' means, the simplest choice would
be writing stuff to a plain text file from the master and reading it
from the slave. This may or may not work depending on your environment
though.

Cheers,
Daniel
--
Psss, psss, put it down! - http://www.cafepress.com/putitdown
Jun 27 '08 #3
On Jun 9, 5:23 pm, "Daniel Fetchinson" <fetchin...@googlemail.com>
wrote:
Suppose I have two different command windows going on the same
machine, each running their own Python interpreters.
Is it possible to access the variables in one of the interpreter-
sessions from the other?
It turns out I have limited control over one of the sessions (i.e.
cannot control all the code that is run from there), but complete
control over the other.
I get the feeling this has been asked before, but I'm not sure how to
pose the question in such a way that it would show up on a search.
It's confusing.

Depending on what 'limited control' means, the simplest choice would
be writing stuff to a plain text file from the master and reading it
from the slave. This may or may not work depending on your environment
though.

Cheers,
Daniel
--
Psss, psss, put it down! -http://www.cafepress.com/putitdown

This disk-writing approach seems to be simplest & less intrusive.
Thanks! I'll try it.

Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Dave Smithz | last post: by
6 posts views Thread by Peter Frost | last post: by
8 posts views Thread by Floris van Haaster | last post: by
5 posts views Thread by Sandman | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.