Seite - 315 - in Programming for Computations – Python - A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
Bild der Seite - 315 -
Text der Seite - 315 -
A.4 HowtoWriteandRunaPythonProgram 315
A.4.2 TextEditors
The most widely used editors for writing programsare Emacs and Vim, which are
availableonall majorplatforms.Somesimpleralternatives forbeginnersare
• Linux:Gedit
• MacOS X: TextWrangler
• Windows:Notepad++
We may mention that Python comes with an editor called Idle, which can be used
to write programs on all three platforms, but running the program with command-
line arguments is a bit complicated for beginners in Idle so Idle is not my favorite
recommendation.
Gedit is a standard program on Linux platforms, but all other editors must be
installed in your system. This is easy: just google the name, download the file, and
follow the standard procedure for installation. All of the mentioned editors come
with a graphical user interface that is intuitive to use, but the major popularity of
EmacsandVim isdue to their richset of short-keysso thatyoucanavoidusing the
mouseandconsequentlyedit at higherspeed.
A.4.3 TerminalWindows
To run the Python program, you may use a terminal window. This is a window
where you can issue Unix commands in Linux and Mac OS X systems and DOS
commandsinWindows.OnaLinuxcomputer,gnome-terminalismyfavorite,but
otherchoicesworkequallywell, suchasxtermandkonsole.OnaMaccomputer,
launch theapplicationUtilities—Terminal.OnWindows, launchPowerShell.
You must first move to the right folder using the cd foldername command.
Then runninga pythonprogramprog.py is a matter of writingpython prog.py.
Whatever theprogramprintscanbeseen in the terminalwindow.
A.4.4 UsingaPlainTextEditorandaTerminalWindow
1. Create a folder where your Python programs can be located, say with name
mytestunderyour homefolder. This is most convenientlydone in the terminal
window since you need to use this window anyway to run the program. The
commandforcreatinganewfolder ismkdir mytest.
2. Move to thenewfolder:cd mytest.
3. Start the editorofyourchoice.
4. Write a program in the editor, e.g., just the line print(’Hello!’). Save the
programunder thenamemyprog1.py in themytest folder.
5. Move to the terminal window and writepython myprog1.py.You should see
thewordHello!beingprinted in the window.
Programming for Computations – Python
A Gentle Introduction to Numerical Simulations with Python 3.6, Band Second Edition
- Titel
- Programming for Computations – Python
- Untertitel
- A Gentle Introduction to Numerical Simulations with Python 3.6
- Band
- Second Edition
- Autoren
- Svein Linge
- Hans Petter Langtangen
- Verlag
- Springer Open
- Datum
- 2020
- Sprache
- englisch
- Lizenz
- CC BY 4.0
- ISBN
- 978-3-319-32428-9
- Abmessungen
- 17.8 x 25.4 cm
- Seiten
- 356
- Schlagwörter
- Programmiersprache, Informatik, programming language, functional, imperative, object-oriented, reflective
- Kategorie
- Informatik