#!/usr/bin/python
str = "this"
if(1):
print "Hi"
else:
print str.any_random_function()
This doesn't fail when I run the program. I tried py_compile but that didn't indicate the error in the else
loop either. Now how can I compile the program and detect errors reliably in python code?
I think your best bet would be pylint.
Python is a dynamic language, so you can't simply check for compiling errors like in static languages (C/C++/Java). If you assign str.any_random_function
, the above code would be correct (okay that's a bad example...).
I'd suggest you to use PyDev for Eclipse which automatically finds many common problems in your code, like missing functions/modules etc. It also supports pylint (optional).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With