Debugging CGI tips wanted...

Erik Max Francis max at alcyone.com
Fri May 16 02:16:32 EDT 2003


"John D." wrote:

> I want to know if there's a way to emulate this from the Python
> command line,  to make debugging easier.

Just pipe your test data in from the command line, or replace sys.stdin.

> Another question....  How can I tell if a Python veriable is undefined
> at runtime.

Easy:

>>> hguhagluahguahg
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'hguhagluahguahg' is not defined

So:

>>> try:
...  hguhagluahguahg
...  print "defined"
... except NameError:
...  print "not defined"
... 
not defined

-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ Behind an able man there are always other able men.
\__/  (a Chinese proverb)




More information about the Python-list mailing list