[Tutor] How to get both 2.6 scripts as well as 3.1 scripts to run at command line?

Richard D. Moores rdmoores at gmail.com
Thu Sep 16 12:18:25 CEST 2010


I forgot to mention that I didn't write that solveCubicEquation.py
script. I paid a pittance to mathtalk-ga at the old Google Answers to
not only write it, but to explain it. I recommend these 2 pages to
those with a mathematical bent:

<http://answers.google.com/answers/threadview?id=433886>
<http://answers.google.com/answers/threadview?id=441538>

And here's "my" solveCubicEquation.py script:
<http://tutoree7.pastebin.com/7v934g6r>


On Thu, Sep 16, 2010 at 02:28, Richard D. Moores <rdmoores at gmail.com> wrote:
> On Thu, Sep 16, 2010 at 00:54, Alan Gauld <alan.gauld at btinternet.com> wrote:
>>
>> "Richard D. Moores" <rdmoores at gmail.com> wrote
>>
>>> Some of the scripts written for 2.6 use libraries not yet available for 3.x.
>>> So I want to know not how to modify them, but how to run them at the command
>>> line.
>>
>> Install 2.x.
>> This is why we keep recommending that beginners stick with 2.x.
>> Its why the 2.x line has not died out and still gets new releases.
>>
>> Eventually the library owners will port their code but until then
>> you need to use the version of python they are written for.
>> You cannot mix them reliably.
>
> I should have stated that I have 2.6, 2.7, and 3.1  installed. The
> scripts are in 2 groups. One written in 2.6 (or 2.5), the other in 3.1. Most
> run fine in the appropriate version of IDLE, or in Wing when I change
> between c:\Python31\pythonw31.exe and c:\Python26\python.exe .  But
> some 2.6 scripts must be run at the command line. All the 3.1 scripts
> do, but not the 2.6's.
>
> So my problem and question is how to set up a command line that will
> run not just the 2.6 scripts that must be run there, but all of them.
>
> And you know what? In thinking through again what my problem was, I
> got the idea to try this, and it worked:
>
> ==================================================
> C:\P26Working\Finished>c:\Python26\python.exe solveCubicEquation.py
> Enter real coefficients a,b,c: 3,2,1
> a is 3.0
> b is 2.0
> c is 1.0
> equation is (x**3) + (3.000000*x**2) + (2.000000*x) + (1.000000) = 0
>
> roots: [(-2.3247179572447463+0j),
> (-0.33764102137762697+0.56227951206230142j),
> (-0.33764102137762697-0.56227951206230142j)]
>
>    After ignoring very small root.real and root.imag,
>    and rounding to 4 significant figures:
>
> root1 is -2.325
> root2 is -0.3376+0.5623j
> root3 is -0.3376-0.5623j
>
> Press Enter to solve another; n to close:
> ==============================================
>
> So thanks to all for trying to help. Without your tries I wouldn't
> have figured it out!
>
> Dick


I forgot to mention that I didn't write that solveCubicEquation.py
script. I paid a pittance to mathtalk-ga at the old Google Answers to
not only write it, but to explain it. I recommend these 2 pages to
those with a mathematical bent:

<http://answers.google.com/answers/threadview?id=433886>
<http://answers.google.com/answers/threadview?id=441538>

And here's "my" solveCubicEquation.py script:
<http://tutoree7.pastebin.com/7v934g6r>

Dick


More information about the Tutor mailing list