While in general, iOS is pretty nifty, it has some pretty annoying limitations, particularly in regards to inter-app communications (more specifically, the lack thereof). While Pythonista doesn’t complete fix this terrible situation, it does provide some really interesting workarounds.
I’d heard of Pythonista when it first launched, but mostly ignored it since it just seemed like just another Python REPL. Now, it is a Python REPL (2.7) and editor, and it also includes its own 2D graphics and multitouch libs so you can make simple interactive apps with it. Where it starts to get really interesting is that it also includes a bunch of modules, that exposes the iOS clipboard, contacts, location, notifications, etc.
Mostly importantly, it has urllib and webbrowser module support that supports iOS URL callbacks. Pythonista itself supports its own URL scheme of course, lending itself to being called remotely.
Another useful app to use in conjunction with Pythonista is Agile Tortoise’s Drafts. It’s a text editor built specifically to interface with other apps and can serve as an easy briding tool.
There are a fair number of tutorials/guides/scripts available online.
First, some general reference:
- Automating iOS: How Pythonista Changed My Workflow – a very good intro of what Pythonista can do
- Pythonista Modules
- handleOpenURL – comprehensive list of iOS URL schemes. This wiki page is also a useful list w/ examples
- x-callback-url interfaces – x-callback-url is used by many apps and is designed to help standardize IPC w/ result codes, etc
- omz:software Pythonista Forum – official forum
And some useful scripts:
- New from Gist.py – this script will make it easier to copy scripts into Pythonista (iOS has restrictions on being able to sync/pull in interpreted code, so Pythonista does not have Dropbox or other syncing built in). Be sure to take a look at all of omz’s gists for some really useful examples (like how to install modules or a simple shell)
- pipista, pipist 2.0 – you can use this script to easily install modules from the pypi repository. Save as ‘pipista.py’ and run like so:
import pipista
import pipista.pypi_install('tornado')
- Pypi.py – another similar installer script (forum post)
- Quickly Import Pythonista Scripts via TextExpander or Bookmarklet – noticing a trend? This should be plenty for getting scripts into Pythonista
- Pythonista 101: The Scripting Community – includes links to lots of scripts
- Chaining Tweetbot, Pythonista, Drafts, and iMessage for URLs
Specific HOWTOs:
- running python scripts with execfile()
- noDoze.py – for keeping iOS device from sleeping
- Dropbox syncing (see also DroboxySync.py
- invoking Safari w/ webbrowser.open()
- exiting Pythonista programmatically – currently not possible
- SimpleHTTPServer – template for running a custom webapp