This would also work, but I like Kevin’s solution.
def getLocation():
try:
if system.util.getSystemFlags() & system.util.CLIENT_FLAG:
location = 1
elif system.util.getSystemFlags() & system.util.DESIGNER_FLAG:
location = 2
except:
location = 0
return location