writing_python_scripts/quickref.tex
author anand
Mon, 08 Nov 2010 01:36:47 +0530
changeset 455 f5b7d0b693d9
parent 335 d5248a15274c
permissions -rw-r--r--
checklist OK
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
335
d5248a15274c Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents: 296
diff changeset
     1
See where python searches for modules:\\
d5248a15274c Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents: 296
diff changeset
     2
{\ex \lstinline|    sys.path|}
296
641a6ee868c0 made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
     3
335
d5248a15274c Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents: 296
diff changeset
     4
Include our own path in PYTHONPATH:\\
d5248a15274c Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents: 296
diff changeset
     5
{\ex \lstinline|    sys.path.append(our_path)|}
296
641a6ee868c0 made the script writing_python_scripts into new form
Nishanth <nishanth@fossee.in>
parents:
diff changeset
     6
335
d5248a15274c Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents: 296
diff changeset
     7
Run certian code only if executed and not if imported:\\
d5248a15274c Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents: 296
diff changeset
     8
{\ex \lstinline|    if __name__=="__main__": #do something|}
d5248a15274c Finished writing_python_scripts
Nishanth <nishanth@fossee.in>
parents: 296
diff changeset
     9