shortcuts — Pythonista URLs and Utilities


The shortcuts module provides utilities for Pythonista URLs that can be used to launch the app, and run or open scripts. You can also launch the Shortcuts app (and run shortcuts) using this module, but support for “native” Python shortcuts in the Shortcuts app is planned for a future version of Pythonista.



Open a given URL using the system’s default app for the URL’s scheme. This is equivalent to, but more light-weight in terms of memory use (which makes it more suitable to use e.g. in the Today widget).

shortcuts.pythonista_url(path='', action='run', args=None, argv=None)

Generates a pythonista3://... URL from a file name/path, an action, and optional arguments.

Possible values for action are:

  • 'run' – Opening the URL will run the script without further prompt.
  • 'open' – Opening the URL will open the script for editing.
  • 'exec' – The script will be embedded as source code in the URL, and opening the URL will show it in Pythonista. The user can then decide to run it (embedded scripts are not run automatically for security reasons).

The path should either be relative to the root “on this device” directory, or have an ‘iCloud/’ prefix, and be relative to the iCloud container directory of Pythonista.

args can be a string that contains arguments that are passed to the script as sys.argv. Alternatively, you can use the argv parameter to pass the arguments as a list.

shortcuts.open_shortcuts_app(name=None, shortcut_input='')

Open the Apple Shortcuts app and optionally run a named shortcut. Equivalent to'shortcuts://run-shortcut?name=[name]&input=shortcut_input').