Page - 212 - in Programming for Computations β Python - A Gentle Introduction to Numerical Simulations with Python
Image of the Page - 212 -
Text of the Page - 212 -
212 A GettingAccesstoPython
A.3.1 TheNeedforaTextEditor
Since programs consist of plain text, we need to write this text with the help of
another program that can store the text in a file. You havemost likely extensive
experiencewithwriting textonacomputer,but forwritingyourownprogramsyou
need special programs, called editors, which preserve exactly the characters you
type. Thewidespreadwordprocessors,MicrosoftWordbeinga primary example,
are aimed at producing nice-looking reports. These programs format the text and
arenot acceptable tools forwritingyourownprograms, even though theycansave
thedocument inapure text format. Spacesareoften important inPythonprograms,
and editors for plain text give you complete control of the spaces and all other
characters in theprogramfile.
A.3.2 TextEditors
Themostwidely used editors forwritingprogramsareEmacs andVim,which are
availableonallmajorplatforms. Somesimpler alternatives forbeginnersare
Linux:Gedit
MacOSX:TextWrangler
Windows:Notepad++
Wemaymention that Python comeswith an editor called Idle,which canbeused
towrite programsonall three platforms, but running the programwith command-
line arguments is a bit complicated for beginners in Idle so Idle is notmy favorite
recommendation.
Gedit is a standard programonLinux platforms, but all other editorsmust be
installed inyour system. This is easy: justgoogle thename,download thefile, and
follow the standard procedure for installation. All of thementioned editors come
with a graphical user interface that is intuitive to use, but themajor popularity of
EmacsandVimisdue to their richsetof short-keysso thatyoucanavoidusing the
mouseandconsequentlyedit at higher speed.
A.3.3 TerminalWindows
To run thePythonprogram,youneeda terminal window. This is awindowwhere
you can issueUnix commands in Linux andMacOSX systems andDOS com-
mands inWindows. On aLinux computer, gnome-terminal ismy favorite, but
otherchoicesworkequallywell, suchasxtermandkonsole.OnaMaccomputer,
launch theapplicationUtilities - Terminal. OnWindows, launchPowerShell.
Youmust first move to the right folder using the cd foldername command.
Thenrunningapythonprogramprog.py is amatterofwritingpython prog.py.
Whatever theprogramprints canbeseen in the terminalwindow.
back to the
book Programming for Computations β Python - A Gentle Introduction to Numerical Simulations with Python"
Programming for Computations β Python
A Gentle Introduction to Numerical Simulations with Python
- Title
- Programming for Computations β Python
- Subtitle
- A Gentle Introduction to Numerical Simulations with Python
- Authors
- Svein Linge
- Hans Petter Langtangen
- Publisher
- Springer Open
- Date
- 2016
- Language
- English
- License
- CC BY-NC 4.0
- ISBN
- 978-3-319-32428-9
- Size
- 17.8 x 25.4 cm
- Pages
- 248
- Keywords
- Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
- Category
- Informatik