python cheat sheet
-
To use python from windows command line, you need to set environmental variable PATH:
-
To directly install library packages to python. Extract the folder pyserial-2.5 from the downloaded tarball to
C:\Python27\Lib\site-packages
. Then, install from the directory:C:\Python27\Lib\site-packages\pyserial-2.5
by runningpython setup.py install
-
Input output file handling from command line python. If you are the only one to use the program and don’t need any defensive programming use this technique.
#!/usr/bin/python
#command line: python posCreate.py spheres.text output.pos
import sys
#for arg in sys.argv: #shows input arguments
# print arg
print 'Input file:'+ sys.argv[1]
print 'Output file:'+ sys.argv[2]
inputFile = open(sys.argv[1], "r+") # files are in your python environment to play with
outputFile = open(sys.argv[2], "r+")
Last modified: 2017-12-31