Python programming | Scripting
Python programming Scripting
Finn A?rup Nielsen
DTU Compute
Technical University of Denmark
July 4, 2014
Python scripting
Overview
How to make a command-line script (as oppose to a module)?
Header
Argument parsing
__main__
Command-line input
Standard input/output and piping
Finn A?rup Nielsen
1
July 4, 2014
Python scripting
Naming
It is not necessary to call a script run from the command-line with the
.py extension.
Actually it might be better to hide the implementation (that it is written
in python) from the user (for some operating systems).
Finn A?rup Nielsen
2
July 4, 2014
Python scripting
Header in Linux-like environment
The hash-bang at the top
#!/usr/bin/python
enabling you to run the script like (after setting of the ecexcution bit with
chmod a+x myscript):
$ myscript
rather than
$ python myscript
or if you are afraid the python program you want is not installed in /usr/bin
(think virtualenv):
#!/usr/bin/env python
Finn A?rup Nielsen
3
July 4, 2014
Python scripting
Header in Windows-like environment
Hashbang does not work in Windows.
If you instead maintain the .py extension then you are able to ASSOC and
FTYPE commands to associate a filetype to a specific program (such as
the python program. See the suggestion on Stack Overflow.
Finn A?rup Nielsen
4
July 4, 2014
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- an introduction to python for absolute beginners
- chapter 9 running python scripts
- micropython basics load files run code
- python scripting with scribus
- public notes running python in azure batch on windows
- python programming scripting
- tutorial 10 python scripting esri
- writing mysql scripts with python s db api interface
Related searches
- python programming books free pdf
- best python programming book
- python programming language pdf book
- free python programming books
- python programming pdf free download
- python programming tutorials
- python programming for absolute beginners
- python programming on win32 download
- basic python programming examples
- python programming examples pdf
- python programming examples source code
- introduction to python programming pdf