473,729 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get all the variables in a python shell

Hi!

I'm currently working on a scientific computation software built in
python.
What I want to implement is a Matlab style command window <->
workspace interaction.

For example, you type 'a=1' in the command window, and you see a list
item named 'a' in the workspace.
You double click the icon of the item, and you see its value. You can
modify the value of the list item,
1 -100 etc, after which if you go back to the command window and
type 'a' and press enter, you see that
varable a's value has been changed to 100.

So my question is : if you have two DOS command windows running under
WINDOWS OS, how can you make them share the same internal variable
buffer? Or is there any easier way to implement such kind of
interaction?

Maybe I could just build a small database to store all the values and
access them from both programs, but chances are sometimes I have to
deal with big arrays, and they will eat extra memory if I keep them in
a database. Is there anyway to access a shell's local memory buffer?
I tried to use shell.interp.lo cals() in wxPython, but there's too many
variables in the list which I don't actually need.

Come on guys, give me some ideas. Thanks in advance!
Jun 27 '08 #1
15 2169
On 2008-05-29, li********@gmai l.com <li********@gma il.comwrote:
Hi!

I'm currently working on a scientific computation software built in
python.
What I want to implement is a Matlab style command window <->
workspace interaction.
ok, although I personally favor the style of writing and running a
script/program, since it scales much better (you can easier automate steps),
and it is much easier reproducible (something you probably want in scientific
software) and storable (in a VCS).
For example, you type 'a=1' in the command window, and you see a list
item named 'a' in the workspace.
You double click the icon of the item, and you see its value. You can
modify the value of the list item,
1 -100 etc, after which if you go back to the command window and
type 'a' and press enter, you see that
varable a's value has been changed to 100.
I do hope you have made a fair estimate of the amount of work that it costs to
change the value of a variable in this way.

I would propose to simply use the interactive Python prompt. It doesn't give
you popup icons for clicking, but you do get the entire Python interpreter, and
all its libraries for free.

The Python library has a frame work for customizing the interpreter. Have a
look at 'cmd' module.
So my question is : if you have two DOS command windows running under
WINDOWS OS, how can you make them share the same internal variable
buffer? Or is there any easier way to implement such kind of
interaction?
Now you have lost me. One window is not enough for interaction?

Obviously, you'll need to have a common interpreter/storage backend. One
solution may be to have a common execution back-end, and for each window a
'frontend' which passes commands entered to the back-end, and echoes results
from the back-end to the terminal.
Maybe I could just build a small database to store all the values and
access them from both programs, but chances are sometimes I have to
deal with big arrays, and they will eat extra memory if I keep them in
They eat memory when you keep them in a data base? It seems, you are making
assumptions about implementations here without telling them.
(ie pick a data base that uses a disk, and your problem is solved. Why is that
not an option?)

Sincerely,
Albert

Jun 27 '08 #2
li********@gmai l.com wrote:
I'm currently working on a scientific computation software built in
python.
What I want to implement is a Matlab style command window <->
workspace interaction.

For example, you type 'a=1' in the command window, and you see a list
item named 'a' in the workspace.
You double click the icon of the item, and you see its value. You can
modify the value of the list item,
1 -100 etc, after which if you go back to the command window and
type 'a' and press enter, you see that
varable a's value has been changed to 100.

So my question is : if you have two DOS command windows running under
WINDOWS OS, how can you make them share the same internal variable
buffer? Or is there any easier way to implement such kind of
interaction?
I stronly suggest you look at IPython [1]. To do what I think
you're describing, you'd need to hack or reimplement the interpreter.
And that's what they've done. ISTR that they even have a branch
which is dealing with parallel instances.

TJG

[1] http://ipython.scipy.org/moin/
Jun 27 '08 #3
li********@gmai l.com wrote:
I'm currently working on a scientific computation software built in
python.
What I want to implement is a Matlab style command window <->
workspace interaction.

For example, you type 'a=1' in the command window, and you see a list
item named 'a' in the workspace.
You double click the icon of the item, and you see its value. You can
modify the value of the list item,
1 -100 etc, after which if you go back to the command window and
type 'a' and press enter, you see that
varable a's value has been changed to 100.

So my question is : if you have two DOS command windows running under
WINDOWS OS, how can you make them share the same internal variable
buffer? Or is there any easier way to implement such kind of
interaction?
I stronly suggest you look at IPython [1]. To do what I think
you're describing, you'd need to hack or reimplement the interpreter.
And that's what they've done. ISTR that they even have a branch
which is dealing with parallel instances.

TJG

[1] http://ipython.scipy.org/moin/
Jun 27 '08 #4
-----Original Message-----
From: py************* *****@python.or g [mailto:py****** ************@py thon.org] On Behalf Of Tim Golden
Sent: Thursday, May 29, 2008 4:11 AM
To: Python-Win32 List; py*********@pyt hon.org
Cc: Python-Win32 List
Subject: Re: [python-win32] How to get all the variables in a python shell

li********@gmai l.com wrote:
I'm currently working on a scientific computation software built in
python.
What I want to implement is a Matlab style command window <->
workspace interaction.

For example, you type 'a=1' in the command window, and you see a list
item named 'a' in the workspace.
You double click the icon of the item, and you see its value. You can
modify the value of the list item,
1 -100 etc, after which if you go back to the command window and
type 'a' and press enter, you see that
varable a's value has been changed to 100.

So my question is : if you have two DOS command windows running under
WINDOWS OS, how can you make them share the same internal variable
buffer? Or is there any easier way to implement such kind of
interaction?
I stronly suggest you look at IPython [1]. To do what I think
you're describing, you'd need to hack or reimplement the interpreter.
And that's what they've done. ISTR that they even have a branch
which is dealing with parallel instances.

TJG

[1] http://ipython.scipy.org/moin/
_______________ _______________ _______________ __
python-win32 mailing list
py**********@py thon.org
http://mail.python.org/mailman/listinfo/python-win32

I'd try looking at memcached (http://www.danga.com/memcached/apis.html). No hacking or reimplementatio n of the interpreter would be necessary, and there's a
Python api available. I haven't used it for anything production related, but I have played with it a bit, and it's fast and stable.

DISCLAIMER:
This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and
may contain legally privileged and/or confidential information. If you are not the intended recipient
of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and
any attachments thereto, is strictly prohibited. If you have received this in error, please immediately notify
me and permanently delete the original and any copy of any e-mail and any printout thereof.
E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept
liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission.

NOTICE REGARDING PRIVACY AND CONFIDENTIALITY
Direct Edge ECN LLC may, at its discretion, monitor and review the content of all e-mail communications.

www.directedge.com
Jun 27 '08 #5
On 29/05/2008, Dahlstrom, Roger <rd********@dir ectedge.comwrot e:
I'd try looking at memcached (http://www.danga.com/memcached/apis.html).
No hacking or reimplementatio n of the interpreter would be necessary, and
there's a Python api available. I haven't used it for anything production related,
but I have played with it a bit, and it's fast and stable.
Is memcached available for Windows, then? I've heard nice things about
it, but thought it was Unix-only.

Paul.
Jun 27 '08 #6
-----Original Message-----
From: Paul Moore [mailto:p.****** *@gmail.com]
Sent: Thursday, May 29, 2008 7:23 AM
To: Dahlstrom, Roger
Cc: Python-Win32 List; py*********@pyt hon.org
Subject: Re: [python-win32] How to get all the variables in a python shell

On 29/05/2008, Dahlstrom, Roger <rd********@dir ectedge.comwrot e:
I'd try looking at memcached (http://www.danga.com/memcached/apis.html).
No hacking or reimplementatio n of the interpreter would be necessary, and
there's a Python api available. I haven't used it for anything production related,
but I have played with it a bit, and it's fast and stable.
Is memcached available for Windows, then? I've heard nice things about
it, but thought it was Unix-only.

Paul.
----------------------------

It is available for Windows, yes. As a matter of fact, I've never used it on Unix.
DISCLAIMER:
This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and
may contain legally privileged and/or confidential information. If you are not the intended recipient
of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and
any attachments thereto, is strictly prohibited. If you have received this in error, please immediately notify
me and permanently delete the original and any copy of any e-mail and any printout thereof.
E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept
liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission.

NOTICE REGARDING PRIVACY AND CONFIDENTIALITY
Direct Edge ECN LLC may, at its discretion, monitor and review the content of all e-mail communications.

www.directedge.com
Jun 27 '08 #7
Tim Golden wrote:
li********@gmai l.com wrote:
>I'm currently working on a scientific computation software built in
python.
What I want to implement is a Matlab style command window <->
workspace interaction.

For example, you type 'a=1' in the command window, and you see a list
item named 'a' in the workspace.
You double click the icon of the item, and you see its value. You can
modify the value of the list item,
1 -100 etc, after which if you go back to the command window and
type 'a' and press enter, you see that
varable a's value has been changed to 100.

So my question is : if you have two DOS command windows running under
WINDOWS OS, how can you make them share the same internal variable
buffer? Or is there any easier way to implement such kind of
interaction?

I stronly suggest you look at IPython [1]. To do what I think
you're describing, you'd need to hack or reimplement the interpreter.
And that's what they've done. ISTR that they even have a branch
which is dealing with parallel instances.
Sorry, having seen Roger D's memcached suggestion, I realise I may
have misinterpreted your requirement. I thought that you wanted
a Python interpreter session to share its objects to another window,
hence my IPython suggestion. If you're writing your own console app
and want to share stuff, then there's any number of IPC possibilities.

Roger's already mentioned memcached which I've no more than a
passing knowledge of. But Pyro [1] is often a good bet for these
things, and the pyprocessing [2] module is gaining a fair bit of
traction at the moment. (To name just two out of many).

TJG

[1] http://pyro.sf.net
[2] http://pyprocessing.berlios.de/

Jun 27 '08 #8
<<< No Message Collected >>>
Jun 27 '08 #9
[Bizarrely, my mail system seems to be randomly misfiring.
If you've already seen this, please ignore!]

Tim Golden wrote:
Sorry, having seen Roger D's memcached suggestion, I realise I may
have misinterpreted your requirement. I thought that you wanted
a Python interpreter session to share its objects to another window,
hence my IPython suggestion. If you're writing your own console app
and want to share stuff, then there's any number of IPC possibilities.

Roger's already mentioned memcached which I've no more than a
passing knowledge of. But Pyro [1] is often a good bet for these
things, and the pyprocessing [2] module is gaining a fair bit of
traction at the moment. (To name just two out of many).

TJG

[1] http://pyro.sf.net
[2] http://pyprocessing.berlios.de/

Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3846
by: Logan | last post by:
Several people asked me for the following HOWTO, so I decided to post it here (though it is still very 'alpha' and might contain many (?) mistakes; didn't test what I wrote, but wrote it - more or less - during my own installation of Python 2.3 on Fedora Core 1 Linux for a friend of mine). Anyway, HTH, L.
20
5191
by: Matthew Thorley | last post by:
My friend sent me an email asking this: > I'm attemtping to decide which scripting language I should master and > was wondering if it's possible to do > these unixy awkish commands in python: > > How to find the amount of disk space a user is taking up: > > find / -user rprice -fstype nfs ! -name /dev/\* -ls | awk '{sum+=$7};\ > {print "User rprice total disk use = " sum}'
3
2226
by: Greg Lindstrom | last post by:
Hello- I am running python 2.3. on an HP-9000 box running Unix and have a POSIX script that sets up my production environment. I would like to run the script from inside a python routine and pick up the environment variables but am having trouble getting it done. Suppose the script is called setprod. How can I call this from inside a python script then pick up the env's later in my program? I've tried os.system ('setprod') and...
3
2965
by: David Durkee | last post by:
Hi, I'm trying to write a script I can run from tcsh in Terminal (on Mac OS X) that will set environment variables that can be accessed by subsequent commands I execute in that session. Not having any luck so far. Here's what I've tried: ------------ #!/usr/bin/python
2
4545
by: Xah Lee | last post by:
Python Doc Problem Example: os.system Xah Lee, 2005-09 today i'm trying to use Python to call shell commands. e.g. in Perl something like output=qx(ls) in Python i quickly located the the function due to its
30
2911
by: bblais | last post by:
Hello, Let me start by saying that I am coming from a background using Matlab (or Octave), and C++. I am going to outline the basic nuts-and-bolts of how I work in these languages, and ask for some help to find out how the same thing is done in Python. I am not sure what the standard is. In C++, I open up an editor in one window, a Unix shell in another. I write the code in the editor, then switch to the shell window for compile...
5
2832
by: Maxim Veksler | last post by:
Hello list, I'm trying to write a python script that would allow me to manipulate shell variables of the calling shell. I'm trying to write some logic that would know to add LD_LIBRARY_PATH to the users environment. In bash this is done with "export", can I do this with python? (If at all possible because python is actually a sub process of bash). Thank you,
1
1133
by: Lee | last post by:
Hi, thank your for your reply. I will try iPython. I did try sage for a while, but I found it quite heavy, and I'm not sure whether it's easy to expand like python or not. New libraries can be easily imported in python, and those libraries could be build in almost any popular computer language. Can sage do that? The reason why I want to work on this is the same with you. I'm an automotive engineer. What I need is a powerful
1
3265
by: Fredrik Lundh | last post by:
John Lawrence wrote: doesn't exactly work for Python scripts, though: $ cat env.py #!/usr/bin/env python import os os.environ = "hello"
0
8913
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8761
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9280
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8144
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.