python Programming Glossary: r'c
How do I concatenate files in Python? http://stackoverflow.com/questions/1001538/how-do-i-concatenate-files-in-python sure. from glob import iglob import shutil import os PATH r'C music' destination open 'everything.mp3' 'wb' for filename in..
Python random lines from subfolders http://stackoverflow.com/questions/12128948/python-random-lines-from-subfolders read from these files. First indexing import os root_path r'C Tasks ' total_lines 0 file_indices dict # Based on http stackoverflow.com..
How do I get all of the output from my .exe using subprocess and Popen? http://stackoverflow.com/questions/12600892/how-do-i-get-all-of-the-output-from-my-exe-using-subprocess-and-popen as s from subprocess import Popen import os ps Popen r'C Tools Dvb_pid_3_0.exe' stdin s.PIPE stdout s.PIPE print 'pOpen.. # usr bin env python from subprocess import Popen PIPE cmd r'C Tools Dvb_pid_3_0.exe' p Popen cmd stdin PIPE stdout None stderr.. as a string from subprocess import check_output as qx cmd r'C Tools Dvb_pid_3_0.exe' output qx cmd To get both stdout and..
How to create new folder? http://stackoverflow.com/questions/1274405/how-to-create-new-folder and use os.path.exists to see if it exists already newpath r'C Program Files arbitrary' if not os.path.exists newpath os.makedirs..
Start Another Program From Python >Separately< http://stackoverflow.com/questions/13078071/start-another-program-from-python-separately os.startfile that does the same thing so just os.startfile r'C Program Files MyGame MyGame.exe' . On FreeDesktop compatible..
Matplotlib: Aligning y-ticks to the left http://stackoverflow.com/questions/15882249/matplotlib-aligning-y-ticks-to-the-left ticks # ha 'left' fig.set_size_inches 12 8 fig.savefig r'C try.png' bbox_extra_artists r bbox_inches 'tight' python matplotlib..
download a zip file to a local drive and extract all files to a destination folder using python 2.5 http://stackoverflow.com/questions/1774434/download-a-zip-file-to-a-local-drive-and-extract-all-files-to-a-destination-fold not good for version 2.5''' import zipfile GLBzipFilePath r'C Users blueman user test2.5.zip' GLBextractDir r'C Users blueman.. r'C Users blueman user test2.5.zip' GLBextractDir r'C Users blueman user' def extract zipFilePath extractDir zip zipfile..
PyQt/PySide - icon display problem http://stackoverflow.com/questions/4573995/pyqt-pyside-icon-display-problem manually. My setup.py looks something like this _PYSIDEDIR r'C Python27 Lib site packages PySide' data_files 'imageformats'..
Python - Test directory permissions http://stackoverflow.com/questions/539133/python-test-directory-permissions results. os.access 'C haveaccess' os.R_OK False os.access r'C haveaccess' os.R_OK True os.access 'C donthaveaccess' os.R_OK.. True os.access 'C donthaveaccess' os.R_OK False os.access r'C donthaveaccess' os.R_OK True Am I doing something wrong Is there..
Python closure not working as expected http://stackoverflow.com/questions/6035848/python-closure-not-working-as-expected get this to function as I expect import os def main files r'C _local test.txt' r'C _local junk.txt' funcs for f in files funcs.append.. as I expect import os def main files r'C _local test.txt' r'C _local junk.txt' funcs for f in files funcs.append lambda os.startfile.. this question One way is to do this def main files r'C _local test.txt' r'C _local junk.txt' funcs for f in files #..
IronPython: EXE compiled using pyc.py cannot import module “os” http://stackoverflow.com/questions/6195781/ironpython-exe-compiled-using-pyc-py-cannot-import-module-os EXE called Fred_Download_Tool import sys sys.path.append r'C Program Files IronPython 2.7 Lib' sys.path.append r'C Program.. r'C Program Files IronPython 2.7 Lib' sys.path.append r'C Program Files IronPython 2.7' import clr clr.AddReference 'IronPython'..
How to use copyfile when there are spaces in the directory name? http://stackoverflow.com/questions/9500735/how-to-use-copyfile-when-there-are-spaces-in-the-directory-name My file.txt' or even better use the r prefix source r'C Documents and Settings Some directory My file.txt' share improve..
Automation Excel from Python http://stackoverflow.com/questions/15467229/automation-excel-from-python excel Dispatch 'Excel.Application' wb excel.Workbooks.Open r'c path to file.xlsx' ws wb.Sheets 'My Sheet' # do other stuff..
How can I capture all exceptions from a wxPython application? http://stackoverflow.com/questions/166198/how-can-i-capture-all-exceptions-from-a-wxpython-application everything import sys sys.stdout OutWrapper sys.stdout r'c temp log.txt' As to logging exceptions the easiest thing to..
Batch Renaming of Files in a Directory http://stackoverflow.com/questions/225735/batch-renaming-of-files-in-a-directory ext You could then use it in your example like this rename r'c temp xx' r' .doc' r'new s ' The above example will convert all..
py2exe com dll problem http://stackoverflow.com/questions/3126379/py2exe-com-dll-problem 12 20 Test urllib.pathname2url # # urllib.pathname2url r'c tung wäi' #' C tung w 84i' # urllib.pathname2url r' tung wäi'..
Python raw literal string http://stackoverflow.com/questions/3517802/python-raw-literal-string raw literal string str r'c path to folder ' # my comment IDE Eclipse Python2.6 When the..
Python “IOError: [Errno 22] Invalid argument” when using cPickle to write large array to network drive http://stackoverflow.com/questions/4226941/python-ioerror-errno-22-invalid-argument-when-using-cpickle-to-write-large For more information type 'help pylab '. In 1 open r'c test.bin' 'wb' .write 'a' 67076095 In 2 open r'c test.bin' 'wb'.. In 1 open r'c test.bin' 'wb' .write 'a' 67076095 In 2 open r'c test.bin' 'wb' .write 'a' 67076096 In 3 open r'z test.bin' 'wb'..
How to save an object in Python http://stackoverflow.com/questions/4529815/how-to-save-an-object-in-python obj output pickle.HIGHEST_PROTOCOL saveobject company1 r'c mypythonobject' Update Since this is such a popular answer I'd..
Strange path separators on Windows http://stackoverflow.com/questions/6928789/strange-path-separators-on-windows because ' ' will produce a backslash or B use raw strings r'c path to my file.txt' . The preceding r will prompt the interpreter..
Using Python's Multiprocessing module to execute simultaneous and separate SEAWAT/MODFLOW model runs http://stackoverflow.com/questions/9874042/using-pythons-multiprocessing-module-to-execute-simultaneous-and-separate-seawa f.split '_' 2 .split '.' 0 print 'Realization s' real mf2k r'c modflow mf2k.1_19 bin mf2k.exe ' mf2k5 r'c modflow MF2005_1_8.. s' real mf2k r'c modflow mf2k.1_19 bin mf2k.exe ' mf2k5 r'c modflow MF2005_1_8 bin mf2005.exe ' seawatV4 r'c modflow swt_v4_00_04.. ' mf2k5 r'c modflow MF2005_1_8 bin mf2005.exe ' seawatV4 r'c modflow swt_v4_00_04 exe swt_v4.exe ' seawatV4x64 r'c modflow..
|