title: Device (Python) description: Python-side Device API mirroring the JS Device namespace: read-only model / system / screen / battery / orientation / locale info.


The scripting Python package exposes Device with read-only properties describing the host device — model, system version, screen, locale, battery, and orientation. Each property fires a single RPC call to fetch the current value; cache the result yourself if you read the same property in a tight loop.

import scripting; Device = scripting.Device

print(Device.model, Device.systemName, Device.systemVersion)

Properties

Hardware identity

NameTypeDescription
Device.modelstrE.g. "iPhone", "iPad".
Device.localizedModelstrLocalized form of model.
Device.systemNamestrE.g. "iOS", "iPadOS".
Device.systemVersionstrE.g. "17.0".
Device.isiPhoneboolThe current device is an iPhone.
Device.isiPadboolThe current device is an iPad.
Device.isiOSAppOnMacboolRunning as an iOS app on Mac (Catalyst-style).

Screen

NameTypeDescription
Device.screendict{"width": float, "height": float, "scale": float}.
Device.colorSchemestr"light" or "dark".

Battery & sensors

NameTypeDescription
Device.batteryStatestr"full", "charging", "unplugged", "unknown".
Device.batteryLevelfloat0.0-1.0, -1.0 if monitoring is unavailable.
Device.proximityStateboolProximity sensor close to user.

Orientation

NameTypeDescription
Device.orientationstr"portrait", "portraitUpsideDown", "landscapeLeft", "landscapeRight", "faceUp", "faceDown", "unknown".
Device.isLandscapeboolDevice is in landscape orientation.
Device.isPortraitboolDevice is in portrait orientation.
Device.isFlatboolDevice is lying flat.

Locale

NameTypeDescription
Device.systemLocalestrCurrent locale identifier, e.g. "en_US".
Device.preferredLanguageslist[str]User-preferred language tags, e.g. ["en-US", "zh-Hans-CN"].
Device.systemLanguageTagstrSame shape as items in preferredLanguages.
Device.systemLanguageCodestrE.g. "en".
Device.systemCountryCodestrE.g. "US".
Device.systemScriptCodestrE.g. "Hans" (empty for languages without explicit script).

Examples

Detect iPad / portrait layout

import scripting; Device = scripting.Device

if Device.isiPad and Device.isLandscape:
    print("Render the wide layout")
else:
    print("Render the narrow layout")

Battery status

import scripting; Device = scripting.Device

state = Device.batteryState
level = Device.batteryLevel
print(f"Battery: {int(level * 100)}% ({state})")

Localized greeting

import scripting; Device = scripting.Device

primary = (Device.preferredLanguages or ["en"])[0]
greeting = "你好" if primary.startswith("zh") else "Hello"
print(greeting)