Check if a script is running in Pythonista 2 or 3
import os | |
import sys | |
import plistlib | |
def get_bundle_identifier(): | |
plist = plistlib.readPlist(os.path.abspath(os.path.join(sys.executable, '..', 'Info.plist'))) | |
return '{CFBundleIdentifier}'.format(**plist) | |
def is_pythonista_3(): | |
return get_bundle_identifier() == 'com.omz-software.Pythonista3' | |
def is_pythonista_2(): | |
return get_bundle_identifier() == 'com.omz-software.Pythonista' | |
if __name__ == '__main__': | |
print(is_pythonista_3()) | |
print(is_pythonista_2()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
PY3 = bytes != str