Check if script is executed within Pythonista
I would like to write multi-platform scripts for Pythonista on iOS, Mac and Windows.
Do you know a way how a script which is executed within Pythonista can check that it is executed within Pythonista and not on a Mac?
Great @stephen thank you! It works well!
@elkrause outstanding! have a good one 🙃
If you're only looking to determine which OS you're on (and not whether you're in the Pythonista IDE specifically), you can do that with:
from sys import platform print(platform)
If you're on iPhone/iPad, platform should be "iOS". If you're on macOS, you should get "darwin". Windows should be "win32" I believe.
almost correct ☺️ heres what i get get from
print(platform.platform())on iPad Air2
Darwin-19.3.0-iPad5,4-64bit might be because of iPadOS?
print(sys.platform) >>> ios
😞 just realised i can never trust the
platformmodule again lol