While waiting for a batch process to finish I had a look at your script. Please take the following as some ideas and remarks, I'm by no means an expert myself and this is supposed to be constsructive criticism 🙂In some of your show* functions you use variables in the function body which you do not pass to your function as arguments. This works in this case but it is fragile as you have to make sure that your variable from the higher scope which you use in the function is defined before your function is called. Why not:def showMessage(message):
print message
showMessage('my testmessage')
instead of def showMessage():
print message
showMessage() # oops
message = 'testing'
It is not usual to use the semicolon syntax in Python. One command, one line - but in the end this is a matter of taste, of course.Please be careful with all these blank except statements. A blank except statement swallows *all* possible python errors and makes it very hard to debug a program. I haven't used my scripts from inside of ArcMap so far, so it might be necessary to do it there. But then again, it might be a good idea to write the traceback at least to your log file.At the moment I do the following in my scripts:try:
gp:Intersect_Analysis('test1.shp; test2.shp', 'out.shp')
except arcgisscripting.ExecuteError:
print gp.GetMessages(2)
This has the advantage that it doesn't silently ignore any other errors I'm not aware of (for example the syntax error which can be found in the snippet). It might have disadvantages when starting scripts from ArcMap of which I'm not aware of at the moment but it may be worth a try. In line #68 it seems as if you want to catch an IOErrorexcept IOError:
....do some stuff....
From #79 on it seems to me as if the license will always be set to 'ArcView'. In an if-elif- statement not all conditions are checked. After the first condition in your if-elif- tree evaluates as `True` the body of that condition is executed and the rest of the elif-else conditions are skipped:>>> a = True
>>> b = True
>>> if a == True:
... print 'a is True'
... elif b == True:
... print 'b is True'
...
a is True
So you need to invert the order of your conditions as ArcInfo is the highest license level - if I'm taken correctly 🙂In #157: do you want to catch a NameError?I hope you don't find these remarks, well, overbearing.