[Tutor] creating interactive program with python
Skipper Seabold
jsseabold at gmail.com
Fri May 29 15:41:44 CEST 2009
On Thu, May 28, 2009 at 7:43 PM, Andre Walker-Loud <walksloud at gmail.com> wrote:
> Hi All,
>
> I am thinking of creating a data analysis suite with python, and I want it
> to be interactive - ie the program asks the user (me) for input, like which
> data file to use, how many parameters to minimize, etc. There are a few
> features I want it to have, like graphing, both the initial data as well as
> results of my analysis, etc. If you are familiar with it, Matlab is close
> to what I would like, a sort of all in one tool - but that is expensive
> commercial software.
>
> So I have a few questions. And I should also say I would classify myself as
> a medium level python scripter, but I have not used the more advanced
> programming features, and I am a beginning programmer. That being said, I
> am interested in expanding my python knowledge, especially getting into the
> more advanced features. Even though this is ultimately just a tool to do my
> job (limiting my time to play around and learn new things) I generally find
> python so easy to use (and fun) that I am interested in this little project
> of mine (and also it will help me sever my dependency on Mathematica, if you
> are familiar with that program).
>
> Thanks
>
> Andre
>
>
>
> 1) I am trying to trying to figure out how I would set up an interactive
> python script, however, I am having trouble googling this, since a search
> for "interactive python" just returns instructions on how to type "python"
> in a terminal to get an "interactive" session....
>
> I have in mind a while loop that asks the user for arguments, and then some
> switch making sure I have passed enough sys.args to proceed, but I am not
> sure how to prompt the user for arguments and count them locally (not a
> global number of sys.argv which is what I am used to now). So any advice on
> where to look at an example of this would be great.
>
> 2) I have come across the "Scipy Superpack"
>
> http://macinscience.org/?page_id=6
>
> which contains Scipy, Numpy, Matplotlib, iPython and PyMC. So it seems the
> installation would be convenient since it is all bundled together. Anyone
> have experience with this package?
>
>
> 3) I see iPython (which I have never used) is an enhanced interactive python
> shell. Perhaps this could do what I want - does anyone have experience with
> iPython? Even if iPython can do everything I want (and more I am sure) I
> would still like to write my own basic little interactive script to expand
> my python knowledge.
>
You might want to have a look at embedding ipython. Here is one take
(more at the link below):
<http://ipython0.wordpress.com/2008/05/15/embedding-ipython-in-gui-apps-is-trivial/>
Note that it plays well with matplotlib and has some *really*
convenient features for doing scientific computing/ data analysis with
Python.
<Tab> completion and being able to issue commands to the system shell
are worth the (free) price of admission alone for me, but that doesn't
even begin to scratch the surface of iPython's nice features.
Have a look at the documentation and the cookbook for tricks and embedding here:
<http://ipython.scipy.org/moin/>
>
> 4) does anyone have strong recommendations for or against using matplotlib?
> Is it low maintenance for producing graphs, or does it take lots of user
> interaction? All the example pictures I see are very pretty, but it is not
> clear how much effort is needed to generate them - or is it just a "well
> know to those who know it well" thing?
>
I have had plenty of luck with iPython, NumPy/SciPy, and matplotlib.
You can see some examples here:
For matplotlib:
<http://www.scipy.org/Cookbook/Matplotlib/>
For Data analysis with SciPy in general (graphical output is not
solely in matplotlib:
<http://www.scipy.org/Cookbook/>
Cheers,
Skipper
More information about the Tutor
mailing list