Debug Shell and Python Script from console
Tuesday, May 19, 2009
> When running Shell script, enable the debug mode with -x option.E.g. sh -x yourscript.sh
> When running Python script, import pdb - the Python debugger, call the set_trace() function and enter n in the console for next debug output. E.g.
> When running Python script, import pdb - the Python debugger, call the set_trace() function and enter n in the console for next debug output. E.g.
#!/usr/bin/python
# epdb1.py -- experiment with the Python debugger, pdb
import pdb
def combine(s1,s2): # define subroutine combine, which...
s3 = s1 + s2 + s1 # sandwiches s2 between copies of s1, ...
s3 = '"' + s3 +'"' # encloses it in double quotes,...
return s3 # and returns it.
a = "aaa"
pdb.set_trace()
b = "bbb"
c = "ccc"
final = combine (a,b)
print final
Labels:
Post a Comment