help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling Octave from Python


From: Paul Thomas
Subject: Re: Calling Octave from Python
Date: Mon, 16 Aug 2004 22:01:06 +0200

Look, I might be a "bear of little brain" but why are you trying to do this?
Python has a perfectly good numeric add-on called Scientific Python -
www.scipy.org

Scipy contains an interface to Gnuplot, which is nearly identical to
octave's.  Each has advantages and disadvantages but I cannot, for the life
of me, see any reason to cal one from the other.  Octave has matlab
compatibility and the consequent friendly arithmetic/math syntax.  Python
does classes like no other.  Choose one or the other. Spend your time
developing the native application in whichever you have chosen!

Paul T

----- Original Message ----- 
From: "Stefan van der Walt" <address@hidden>
To: "Maurice Ling" <address@hidden>
Cc: <address@hidden>
Sent: Monday, August 16, 2004 9:14 AM
Subject: Re: Calling Octave from Python


> The problem is that Octave does not close, so that readlines() cannot
> return.  Try something like
>
> ----
> import os, string
>
> [pwrite, pread] = os.popen3("/usr/bin/octave -q")
>
> pwrite.write("x = [1,2,3];\n")
> pwrite.write("printf('%f\\n', sum(x));\n")
> pwrite.flush()
> pwrite.close()
>
> result = pread.readlines()
> pread.close()
>
> print ("Sum = %s" % result[0])
> ----
>
> Regards
> Stefan
>
> On Mon, Aug 16, 2004 at 12:43:42PM +1000, Maurice Ling wrote:
> > Hi,
> >
> > I've been trying to find a way to call Octave from Python and a previous
> > message in this list uses the following codes...
> >
> > import os
> > import string
> >
> > # make sure to call ocatve with the "quiet" flag
> > [pwrite, pread] = os.popen2("octave -q","w")
> >
> > pwrite.write("x = [1,2,3];\n")
> > pwrite.write("printf('%f\\n', sum(x));\n")
> >
> > # always flush the output to avoid deadlocks
> > pwrite.flush()
> > result = pread.readline()
> > print ("Sum = %f" % string.atof(result))
> >
> > pwrite.close()
> > pread.close()
> >
> >
> > But python freezes itself after "result = pread.readline()". I'm
> > wondering what is wrong?
> >
> > Thanks
> > Cheers
> > Maurice
> >
> > -- 
> > Maurice Han Tong LING, BSc(Hons)(MCB), AdvDipComp, SN
> > Doctor of Philosophy (Science) Candidate, The University of Melbourne
> > mobile: +61 4 22781753
> > +65 96669233
> > mailing address: Department of Zoology, The University of Melbourne
> > Royal Parade, Parkville, Victoria 3010, Australia
> > residential address: 9/41 Dover Street
> >         Flemington, Victoria 3031, Australia
> > email: address@hidden
> > resume: http://maurice.vodien.com/maurice_resume.pdf
> > www: http://www.geocities.com/beldin79/
> >
> > The information contained in this message, including its attachment(s),
> > is CONFIDENTIAL and solely intended to its addressee(s) only. The
> > content of this message, including its attachment(s),  may be subjected
> > to copyright and privacy laws. If you have received this email in error,
> > please let me know by returning this email, and then destroy all copies.
> >
> > "I cannot discover anyone knows enough to say definitely what is
> > and what is not possible" -Henry Ford
> > "The difference between the impossible and the possible lies
> > in a person's determination" -Tommy Charles Lasorda
> >
>
> > begin:vcard
> > fn:Maurice Ling
> > n:Ling;Maurice
> > org:The University of Melbourne;Department of Zoology
> > adr:;;Gate 12, Genetics Lane;Parkville;Victoria;3010;Australia
> > email;internet:address@hidden
> > title:Probatory Ph.D. Candidate
> > tel;cell:+61 4 22781753
> > x-mozilla-html:FALSE
> > url:http://www.geocities.com/beldin79/
> > version:2.1
> > end:vcard
> >
>
>
>
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
>
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------
>



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]