Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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())
@cclauss

This comment has been minimized.

Copy link

@cclauss cclauss commented Apr 3, 2020

PY3 = bytes != str

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.