Check if a script is running in Pythonista 2 or 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
PY3 = bytes != str