[Tutor] From Text Editor to Interpreter

alan.gauld@bt.com alan.gauld@bt.com
Fri, 19 Jul 2002 14:06:01 +0100


------_=_NextPart_001_01C22F25.0830B360
Content-type: text/plain; charset="ISO-8859-1"

>  My question is: what steps must a rank amateur take to write the programs

>  in a text file and then run them with the interpretor? I've downloaded
ConTEXT,  
>  which saves text as a Python file, but how do I run such programs as the

>  Spam salad recipe in Python?  
 
First I'd recommend taking a look at Danny Yoo's IDLE 
tutor before going further. 
 
However having got the text into a file ending .py
(Lets call it first.py) then you have several options 
on how to run it:
 
1) Double click in explorer - snag, this will run it so 
fast you probably wont see the output as it flashes past!
 
2) Assuming you are in Windowsland! Start a MS DOS box 
(I usually do Start->Run and type COMMAND in the dialog)... 
In the resultant window with a prompt like:
 
C:\WINDOWS>
 
Change to the directory/folder where you saved first.py 
and then type python first.py. 
 
ie:
 
C:\WINDOWS> cd C:\PROJECTS\PYTHON
C:\PROJECTS\PYTHON> python first.py
 
You should see the output in your window before returning to the
 
C:\PROJECTS\PYTHON> 
prompt
 
3) Use IDLE (or Pythonwin if you downloaded the 
Activestate version of Python)
 
IDLE makes it much easier, read Danny's tutor :-)
 
Alan g.
Author of the 'Learning to Program' web site
http://www.freenetpages.co.uk/hp/alan.gauld
<http://www.freenetpages.co.uk/hp/alan.gauld>  


------_=_NextPart_001_01C22F25.0830B360
Content-type: text/html; charset="ISO-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">


<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>&gt; &nbsp;</FONT></SPAN>My question is: what steps must a rank amateur 
take to write the programs&nbsp;<SPAN class=970080513-19072002><FONT 
face="Courier New" color=#0000ff size=2>&nbsp;</FONT></SPAN></DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>&gt; </FONT>&nbsp;</SPAN>in a text file and then run them with the 
interpretor? I've downloaded ConTEXT,&nbsp;<SPAN class=970080513-19072002><FONT 
face="Courier New" color=#0000ff size=2>&nbsp;</FONT></SPAN></DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>&gt; </FONT>&nbsp;</SPAN>which saves text as a Python file, but how do I 
run such programs as the&nbsp;<SPAN class=970080513-19072002><FONT 
face="Courier New" color=#0000ff size=2>&nbsp;</FONT></SPAN></DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>&gt; </FONT>&nbsp;</SPAN>Spam salad recipe in Python?&nbsp;<SPAN 
class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>&nbsp;</FONT></SPAN></DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>First I'd recommend taking a look at Danny Yoo's IDLE 
</FONT></SPAN></DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>tutor before going further.</FONT>&nbsp;</SPAN></DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>However having got the text into a file ending .py</FONT></SPAN></DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>(Lets call it first.py) then you have several options 
</FONT></SPAN></DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>on how to run it:</FONT></SPAN></DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>1) Double click in explorer - snag, this will run it so 
</FONT></SPAN></DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>fast you probably wont see the output as it flashes 
past!</FONT></SPAN></DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>2) Assuming you are in Windowsland! Start a MS DOS box 
</FONT></SPAN></DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>(I usually do Start-&gt;Run and </FONT></SPAN><SPAN 
class=970080513-19072002><FONT face="Courier New" color=#0000ff size=2>type 
COMMAND in the dialog)... </FONT></SPAN></DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>In the resultant window </FONT></SPAN><SPAN 
class=970080513-19072002><FONT face="Courier New" color=#0000ff size=2>with a 
prompt like:</FONT></SPAN></DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>C:\WINDOWS&gt;</FONT></SPAN></DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>Change to the directory/folder where you saved first.py 
</FONT></SPAN></DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>and then </FONT></SPAN><SPAN class=970080513-19072002><FONT 
face="Courier New" color=#0000ff size=2>type python first.py. 
</FONT></SPAN></DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>ie:</FONT></SPAN></DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>C:\WINDOWS&gt; cd C:\PROJECTS\PYTHON</FONT></SPAN></DIV>
<DIV><SPAN class=970080513-19072002><FONT face="Courier New" color=#0000ff 
size=2>C:\PROJECTS\PYTHON&gt; python first.py</FONT></SPAN></DIV>
<DIV><SPAN class=970080513-19072002></SPAN>&nbsp;</DIV>
<DIV><SPAN class=970080513-19072002>You should see the output in your window 
before returning to the</SPAN></DIV>
<DIV><SPAN class=970080513-19072002></SPAN>&nbsp;</DIV>
<DIV><SPAN class=970080513-19072002>C:\PROJECTS\PYTHON&gt; </SPAN></DIV>
<DIV><SPAN class=970080513-19072002>prompt</SPAN></DIV>
<DIV><SPAN class=970080513-19072002></SPAN>&nbsp;</DIV>
<DIV><SPAN class=970080513-19072002>3) Use IDLE (or Pythonwin if you downloaded 
the </SPAN></DIV>
<DIV><SPAN class=970080513-19072002>Activestate version of Python)</SPAN></DIV>
<DIV><SPAN class=970080513-19072002></SPAN>&nbsp;</DIV>
<DIV><SPAN class=970080513-19072002>IDLE makes it much easier, read Danny's 
tutor :-)</SPAN></DIV>
<DIV><SPAN class=970080513-19072002></SPAN>&nbsp;</DIV>
<DIV><SPAN class=970080513-19072002>
<P><FONT size=2>Alan g.<BR>Author of the 'Learning to Program' web site<BR><A 
target=_blank 
href="http://www.freenetpages.co.uk/hp/alan.gauld">http://www.freenetpages.co.uk/hp/alan.gauld</A></FONT> 
</P></SPAN></FONT></SPAN></DIV></DIV></BODY></HTML>

------_=_NextPart_001_01C22F25.0830B360--