try: mxd = arcpy.mapping.MapDocument("current") except: print "in arccatalog!"
Rather inelegant, but should accomplish what you want.try: mxd = arcpy.mapping.MapDocument("current") except: print "in arccatalog!"
# Prints "where" script is running from. (e.g. ArcMap, ArcCatalog, python, PythonWin, etc.) import os, sys, arcpy RunFrom = os.path.splitext(os.path.basename(sys.executable))[0] print RunFrom print arcpy.AddMessage(RunFrom)
You can do it like this:# Prints "where" script is running from. (e.g. ArcMap, ArcCatalog, python, PythonWin, etc.) import os, sys, arcpy RunFrom = os.path.splitext(os.path.basename(sys.executable))[0] print RunFrom print arcpy.AddMessage(RunFrom)