As nice as it is to write a for-my-eyes-only script to solve a specific problem on my Mac, it is satisfying in an entirely new way to write code on a mobile device. It just feels less like "programming" and more like making a better pocket knife.

A mundane problem I wanted to solve:

I love budgeting, but not as much as I love food. It's always been a struggle for me to manage what I'm spending eating out over the course of a month—especially since what my family and I spend at restaurants tends to vary a lot in size and frequency.

It's easy to set a food budget at the beginning of the month, and it's easy to see whether we came in under or over that budget at the end of the month, but it's a lot harder to ascertain whether or not I'm on track as the days of the month tick by.

The pocket knife solution:

I wrote a simple Python script in Pythonista that takes a monthly dollar figure—my remaining food budget for the month—and averages it over the remaining days in the current month:


import datetime, calendar
import sys
import console

budget = float(sys.argv[1])

d = datetime.datetime.today().day
m = datetime.datetime.today().month
y = datetime.datetime.today().year
last = calendar.monthrange(y,m)[1]

remaining_per_day = budget / (last - d)
message = 'You have $' + str(round(remaining_per_day,2)) + ' remaining per day for the next ' + str(last - d) + ' days.'

console.clear()
print message

The Python script itself is fairly unremarkable, but what impressed the hell out of me is that I was able to write it entirely on my iPhone, then slap a "GUI" on it using Launch Center Pro.

I don't even have to open Pythonista to use it. I just tap a Launch Center Pro action, enter a dollar figure, and Launch Center Pro sends it to Pythonista, which runs the script and puts an answer in the console.

  <img src="/img/img.gif" alt=""/>

This little workflow takes advantage of Pythonista's ability to accept standard input via its URL scheme and Launch Center Pro's ability to send a URL that consists partly of numeric keypad input.

   [caption id="" align="alignnone" width="400.0"]<img src="/img/img.png" alt="In LCP's action settings, enter Pythonista's URL scheme in the URL field along with [prompt-num], which is LCP's variable for keypad input. The name of the Python script in this example is Budget.py."/> In LCP's action settings, enter Pythonista's URL scheme in the URL field along with [prompt-num], which is LCP's variable for keypad input. The name of the Python script in this example is Budget.py.[/caption] 

This was a mundane problem, but the solution feels remarkable.

To me, Pythonista is a very important app because it feels like an obvious step toward a future where more software creation will happen on devices that we don't think of as "computers" in the conventional sense.

Maybe I'm overblowing all this, but I just think it's amazing that I can write a piece of code on a mobile device, then snap a few blocks together to essentially create a custom app. I can't help but think the future of programming won't feel like "programming"—much like using an iPhone doesn't feel like "computing."

Other resources

Some of the media elements in this post are best viewed in the original.