Pythonista 1.5 – What's New (and What's Missing)

TL;DR: Pythonista 1.5 has passed Apple's review and will be out on Monday today.

If you follow me on Twitter, you know that I've been having some problems getting through Apple's review with my apps Pythonista and Editorial. After I submitted Editorial 1.1.1 (a minor bugfix release), I was informed that the review would take longer, then it was rejected, and things got even worse when I got an email from Apple telling me that "upon re-evaluation", they found that Pythonista "is not in compliance with the App Store Review Guidelines", and that I'd have to submit an update within 48 hours, or my app "may be removed from the App Store".

This is something I've never had to deal with before – when an update is rejected, it's inconvenient, but this usually doesn't affect the existing version. The threat of having an app kicked out of the store – an app that I didn't even submit an update for – now that is some scary stuff. Pythonista is responsible for about 60% of my revenue, and only one update has ever been rejected (for something that was totally my fault).

It's fine with me that Apple occasionally re-evaluates apps that have been approved in the past – but giving me just 48 hours to respond, for an app that has been in the store for almost two years and that has an excellent reputation with 90% 5-star ratings (959 out of 1064, all countries combined) – this is really quite disappointing.

On to the good news. After I submitted an update within Apple's deadline, it was approved pretty quickly. Fortunately, 1.5 was almost done already, so this update doesn't just remove the things Apple objected to, but also brings a lot of new features and modules.

What's Missing

So what was the problem Apple had with the previous version? Turns out, they didn't like the Open in... menu integration I had added in 1.4 because that would allow you to import executable code from external sources. My theory is that this policy is in place to prevent apps that circumvent the App Store, e.g. by offering downloadable games that don't go through Apple's review (and revenue chain via in-app purchases). Like Michael Tsai, who wrote a blog post about this, I don't think it has anything to do with security.

All the apps in question are, of course, sandboxed, so this is not about security. And it’s not as if Pythonista is trying to be an app store within an app. It’s just a productivity app, in fact one of the primary examples of how iOS can be used for more than just content consumption.

I'm sad to see this feature go. It wasn't just a convenient way to import scripts, it also enabled some pretty interesting automation workflows that could process the contents of pretty much any kind of file you could access on your iOS device.

Note that this does not affect Pythonista's ability to transfer files to other apps – in fact, there's a new console.open_in function to do just that.

Due to the tight deadline, Xcode export also didn't make it into this release, but you can download an Xcode project template here: → PythonistaProjectTemplate.zip – just paste your script into it, and you should be able to build it as a standalone app (this still requires a paid iOS Developer Program membership of course).

What's New

Pythonista 1.5 is a pretty big update, perhaps the biggest yet in terms of new Python modules that you can use in your scripts.

First, there are NumPy and matplotlib, both have been requested a lot. NumPy is a popular (de-facto standard) package for efficiently working with n-dimensional arrays. Matplotlib is an extremely powerful plotting library for visualizing all kinds of data. Just have a look at the samples gallery (also included in Pythonista's in-app documentation) to get an idea of what this is capable of.

matplotlib sample gallery

Apart from being very powerful, matplotlib is also remarkably easy to get started with. The following three lines of code are enough to get a basic line plot:

import matplotlib.pyplot as plt
plt.plot([1, 2, 4, 3.5, 2, 2.2])
plt.show()

Result (saved directly from Pythonista's console output):

plot result

The other big new module is called ui. I've introduced it in Editorial 1.1, and I'm excited to bring this to Pythonista as well. As the name implies, this allows you to create custom, native user interfaces for your scripts. It is not a full UIKit wrapper, but it enables you to use a lot of different widgets, like text views and labels, image views, switches and sliders, and even web views for embedding HTML content (and JavaScript). You don't even have to write a lot of code to set things up, because there's an integrated visual UI Editor included. This allows you to design your UI visually, and then connect events to functions in your code.

UI Editor Screenshot

There are three new UI samples included with the app (a calculator, the color mixer shown above, and a very simple drawing app) – I can't wait to see what you come up with, and I'll have a few more demos to share soon.

In terms of improvements in the actual app (vs. Python modules), there are two things I want to highlight. First, the documentation has received a facelift, and it's now shown in the console panel instead of a modal fullscreen view. This means that you can more easily switch between your code and the documentation.

Second, there's a new code completion system that is based on the jedi library by David Halter. To be honest, this is somewhat experimental at this point, if you run into issues, you can disable it with the new Extended Code Completion switch in the settings. It doesn't fully replace the old completion system, it merely supplements it by providing completions in cases that the old system couldn't handle. The old system was primarily based on the documentation index, and doesn't do much to actually analyze your code. Because of this, it is much faster than jedi, but it cannot handle things like instance members, where the type of the object you're dealing with has to be inferred from the surrounding code.

As I said, this is a bit experimental, and I wish there would have been more time to test this. It can also be somewhat slow when you're dealing with large modules, especially on older devices. This actually applies to the entire update. I had 48 hours to submit it, so this definitely feels a bit rushed, and I'm sure that I've missed a few bugs.

So that's it, a quick overview of what you can expect in the new Pythonista – for even more details, head over to the full release notes (also available in the in-app documentation).

I hope you enjoy this update. If you have any questions, say hi on Twitter or write an email. I also really appreciate seeing reviews in iTunes.