Coding with Python on an iPad with Pythonista

Bloggedin
5 min readJul 15, 2020

--

You can code on an iPad.

So recently I turned my devices upside down again if you have been following along you will know that I recently made the switch to an Ipad Pro. After trying a myriad of devices previously I have always had this constant battle to find the perfect device and for me at least the IPad is most of the way there. I really like the interaction either via a pencil, hands or the magic keyboard it truly is a device that adapts to many scenarios and creates for a delightful workflow.

As with most devices complete perfection requires a couple of compromises and previously the iPad legacy has been aimed as a consumption device but times are changing. The attraction to an iPad is that it’s very lightweight and has a great all day battery, but wait I am a developer surely a “proper” computer is of more use? Well hopefully over the next few articles I am going to introduce you to a few Apps that can make you transcend to computing differently. Python still remains my weapon of choice when it comes to coding due to its versatility, not going to start any language wars here but you really can prototype projects fast with Python and due to its versatility you are not constrained to a particular niche of development.

Pythonista

So what is Pythonista?

http://omz-software.com/pythonista/

Pythonista 3 is full Python IDE App for iOS, note this is a paid App costing £9.99 in the UK. Pythonista is a complete development environment for writing Python scripts on your iPad or should you wish your iPhone. Pythonista includes the standard Python library, as well as support for native iOS features such as contacts, reminders, photos, location, motion sensors etc should you wish to make scripts that own your iPad. For me I focus on the standard library so that the code I write on the iPad is transferable rather than being closed in the iOS ecosystem although the UI Editor that is included will be worth exploring at some point so I can create my own niche Apps.

As well as the full featured code editor which provides syntax highlighting and smart code completion you also have a nice interactive shell just as you would on any other Python installation.

Further to the standard Python library, the developers are adding additional modules all the time such PIL, NumPy and MatPlotLib. A killer feature they added was documentation, you can read the entire Python documentation within the App even if offline.

Modules

You can read details on the modules here (the list does changes as the developers add more features)

However I will list out below the current inclusions (with the exception of the standard library) so you can see why it’s definitely worth the purchase price.

arrow, Bs4 (Beautiful Soup 4) for webscraping, Bottle a python web framework (yes you can run it on the iPad and build web Apps that spawn in your browser, I actually use Flask rather than bottle), certifi, cssselect, dateutil, ecdsa, Evernote, faker, feedparser, flask, html2text, html5lib, httplib2, images2gif, itsdangerous, jinja2, markupsafe, markdown, markdown2, midiutil, oauth2, openpyxl, paramiko, parsedatetime, PIL, py, pycparser, pygments, pyparsing, PyPDF2, pytest, pyminizip, pytz, qrcode, reportlab, requests, simpy, six, sqlalchemy, urllib3, wavebender, werkzeug, xmltodict and yaml.

As you can see its quite a list and should cover most if not all of you Python Coding needs.

The interface itself is simple and clearly laid out, for those that like themes you can change the theme to match how you like to work but I find the default nice on the iPad. I tend to use Pythonista in landscape that way I can run a split screen with the console and also can use the side by side feature of iPadOS to have reference material open. I find this a very productive way of working I can have either a browser window open next to pythonista or if I am working through a book I tend to buy the digital version and run it next to the App in side by side view.

Note that the App also features a handy shortcut keyboard for those python typical difficult to reach characters.

For my requirements this is more or less a complete developing application for Python on the iPad so far I have not come short of libraries I frequently use. There is an application called Stash that you can bolt into pythonista, this will allow for adding a pip command to pythonista for adding additional modules but so far I have found the default modules more than adequate for my work flow.

So effectively you can use Pythonista as a main IDE to do all Python your work on the iPad. Or you can use it simply as a mobile Python application to write code on the go prior to sharing it to your main device and refining.

If an iPad is your only device and you want to learn coding then I would really recommend paying for this App as it’s the closest thing to a native running Python installation you are going to get.

The only negative comment I have for the App is that it does not come with source control interfacing, for me having integration with GitHub would make this a diamond application, in absence of this I currently manually upload my scripts via the GitHub online repository upload. I believe you can integrate pythonista with working copy to GitHub integration but for me at least I am not keen on this approach of using an App with an App to perform a job seems more like a work around than a solution, hopefully an updated release of pythonista will bring in source control.

So if you are keen to learn Python and perhaps you only have an iPad or you want to move your children along but they don’t have a computer Pythonista is a great App to purchase for them as an iPad is a relatively cheap multi use device for their education and now that the standard iPad includes keyboard and pencil support you can set yourself up with a highly mobile, lightweight coding device that offers a unique approach to coding.

--

--

Bloggedin

Author of https://www.bloggedin.co.uk, Coding Python, Raspberry Pi, micro:bit, IoT and Node-RED.