[SciPy-user] Pros and Cons of Python verses other array environments

John Hassler hasslerjc at adelphia.net
Thu Sep 28 15:56:15 CDT 2006


Gael Varoquaux wrote:
>  John,
>
> [snippage]
>
> Maybe python can seem harder because it can be used at higher levels. I
> still thing that it is lacking an IDE where you can "click and start
> typing".
>   

But that's exactly my point.  For the most common sort of calculations 
one does as an undergraduate, using Python is exactly like using Matlab, 
with trivial differences.  Here's a little homework problem - 
calculating the flow velocity in a packed column.  This requires the 
solution of a quadratic equation:

Click on Idle.  Then start typing:

Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit 
(Intel)] on win32
Type "copyright", "credits" or "license()" for more information.

    ****************************************************************
    Personal firewall software may warn about the connection IDLE
    makes to its subprocess using this computer's internal loopback
    interface.  This connection is not visible on any external
    interface and no data is sent to or received from the Internet.
    ****************************************************************
   
IDLE 1.2     
 >>> from numpy import *     # Yes, I know, but ...
 >>> rho = 62.4
 >>> rhop = 160.                  # Use decimal point, or use from 
__future ...
 >>> psi = 0.95
 >>> Dp = 0.02/12
 >>> mu = 1*6.72e-4
 >>> eps = 0.42
 >>> g = 32.174
 >>> a = 1.75*rho/(psi*Dp*eps**3)
 >>> b = 150.*mu*(1-eps)/((psi*Dp)**2*eps**3)
 >>> c = g*(rhop - rho)
 >>> print a,b,c
14918.248001   314771.892136   3140.1824
 >>> roots([a,b,-c])      
array([-0.34783557,  0.00969792])
 >>>
Velocity is 0.097 m/sec.

This is how the students use Matlab - the problems are longer, but the 
basic idea is the same.

You also say:

Gael:  "But I use object oriented programming, importing modules, 
functional programming, regexp, operator overloading, and some of my 
colleagues have difficulties with this."

Do they also have difficulty doing these in Matlab???????  (You can't 
even DO most of these in Matlab.  Most Matlab users wouldn't even 
recognize the words.)  (Ok, ok, ad hominem towards Matlab, I apologize.)

john



More information about the SciPy-user mailing list