Python Questions - July 25, 2015

Jonas Wielicki jonas at wielicki.name
Sat Jul 25 12:58:51 CEST 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Hi,

These are quite a few questions and I’ll try to answer some of them. I
have cut out the windows specific questions because I cannot answer them
.

On 25.07.2015 11:39, E.D.G. wrote:
> At the moment our Perl programs use Windows "Pipes" plus files in 
> an interactive mode to send data to Gnuplot so that the data can
> be plotted. That actually produces good results.  But it is a
> complex and inefficient process.  So part of the conversion process
> involves learning how to have Python or some other program plot
> data in the same interactive mode.

Using pipes should be no problem, but for plotting, see below.

> It has been my experience that sending large amounts of data from 
> one program to another using a Windows pipe doesn't work very well.
> So files are presently being used for bulk data transfers.

This may be off topic, but I guess that should in fact be fast.
Otherwise, have you tried using localhost TCP sockets?

> 2.  SPECIFIC CODE QUESTIONS

> 2.  Graphics - This is likely a fairly complicated question.
> 
> What are some of the graphics options available with Python?

Python comes with support for tk and there are bindings available for
Qt and Gtk, but I think for your special use case, there are better
options.

> Does it have its own internal graphics routines?  Perl does not as 
> far as I can tell.  And we never had time to explore Fortran's
> graphics capabilities.
> 
> I am aware of the existence of Matlab.  But as stated, everything 
> involved with this present effort has to be a free download so
> that programmers around the world can easily and inexpensively
> generate program subroutines etc.

There is a python package called matplotlib [1]. I think it’s
interface is in fact inspired by Matlab and it provides powerful and
interactive plotting capabilities.

> 3.  Fast Calculations
> 
> It is my expectation that Python by itself does not do calculations
> very fast when compared to a language such as Fortran.

You are correct.

> 
> So, what options are available for increasing the speed of Python 
> calculations?

Numpy and Scipy [2] are packages which were made just for that.

> 
> Python could call a Fortran program to do the calculations just as 
> Perl could.  But we would like to avoid having to use more than
> one language with this effort.

In fact, Numpy and Scipy use compiled Fortran code as far as I know --
but that is of no matter for a python user, they just see the very
comfortable pythonic interface.

> 6. What is Python's version of the DOS level "System" command that
> many programs use as in:
> 
> system "open notepad.exe"

import subprocess
# this blocks until `open` returns
subprocess.check_call(["open", "notepad.exe"])
# returns immediately, `open` continues to run in the background
subprocess.Popen(["open", "notepad.exe"])


regards,
jwi

   [1]: http://matplotlib.org/
   [2]: http://docs.scipy.org/doc/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCgAGBQJVs2vbAAoJEMBiAyWXYliKAeYP/3463zB43n4f5xcQXR0wdzWb
Hea4qRuZdDyA/FywgNSay8KZ1tUKCk/LWL7rrP8Dpy2oBagdCYICdxJ11X0i0Oz/
3fRVj1mbvYC3i4StcGH/wfz54bDsKF3whVtpTqF/Kz9dgSf6KeM608GdfI/yPSjv
xh0dRuhkaf62Mx/PD3uhLGhHAxB9ZQhoYXlN8Mbc0sKzhnTJJIR4gfBhKSfpxzta
33hiRDXuHDx7zTO5AlIudFk+UGycrH8WGvsQ4fw/PhPEvOcFQz544GKo/+qCKGi0
y6QMtpchdhay3dZKc8ova8pF4ITdlU2Ojt+7MB4AthquNwje+rD4M388PFfQUWGf
yMnWN3vato+uPUWECyi+bktKKS79McFDLn7QdncJI5lGZ216d8Y2uCWVyAw5aie3
2sweWnXmXy/zCeqnn4I4EfWO1jbMZ3fUitf7+rRywmGmq/1GhYg5TDgCC3GIYotU
lrETp3Cpt0VCeELpQAODp+BWhU2z/n7Zf4FTrAsb5Ncxw9N08LgiJy0gaoAxGplb
jabDFUka0Viof+TY/N8GYdoowR8AZA7E+1h0+aReWqW6N9H7YMpBdgLtI0BOHcuc
vBVPWFUg8UtIYCQxLqkcQHb5UXq//eOsl9Bf6tPYWTVxAk4WfLxXE48Udj6Vu6E8
sa2zaDL0kMgoTowiF6Sr
=tkL5
-----END PGP SIGNATURE-----


More information about the Python-list mailing list