Forum Archive

Programatically retrieve device on which the script is running

honekamp

Please pardon me if this topic has already been discussed, but is there any way to programatically find out whether a script is running on an iPhone or on an iPad and make the script behave accordingly?

Thank you,

Uwe

mikael

@honekamp, googled ”pythonista device info” and found this.

JonB

sys.platform gives 'ios' in pythonista.
platform.machine() returns the hardware, such as Ipad3,3 on my devuce, and probably the iphone version on others.

Of course, you can also checkui.screen_size.

honekamp

@JonB Thanks for the hint, platform.machine() does the job for me. I read about it in the documentation and falsely assumed that this was about the processor architecture. Should have given it a try.