from AppKit import NSWorkspace
activeAppName = NSWorkspace.sharedWorkspace().activeApplication()[
    'NSApplicationName']
print(activeAppName)
Finding the Current Active Window in Mac OS X using Python