I have never done Python programming before but I have done a lot of .NET in C# There is a need to do some Python and was trying to learn how to throw exceptions in Python.
from __future__ import with_statement
import dbi
import timeit
import datetime
import win32com.client
import os
import datetime
import sys
import codecs
import subprocess
import time
import _winreg
def main():
retCode=0
now = datetime.datetime.now()
print "-----------------------------------------------------"
print "Start Executing the script", now
print "-----------------------------------------------------"
try:
print "Testing Testing"
except Exception, err:
sys.stderr.write('ERROR: %s\n' % str(err))
retCode=1
if retCode==1:
print "======================================"
print "Errors occured. Please investigate. "
print "======================================"
else:
print "======================================"
print "No errors found"
print "======================================"
print "Retcode:", retCode
sys.exit(retCode)
main()
Does anyobody know why the above code gives me this error ?
The error is:
File "c:\sample.py", line 28
retCode=1
^
IndentationError: unexpected indent
main()function would be to useif __name__ == '__main__':.