A common task I have: I want to write down some numbers or a simple formula of some kind, and then go ahead and do something with the numbers or solve a simple equation with them. Examples: writing down how much I paid for each bill in a note or drafts, then summing them; working out a simple algebra equation for something like a mildly complicated tax/tip situation and then solving it.
There are lots of calculators in the built-in Pythonista examples, but none which quite met my needs for dealing with pre-written text. There are also special-purpose apps for things like ticker-tape calculators, but I don't think any of them do algebra, and, besides, why pay for a separate app when pythonista is right there plus has the full power of sympy available?
So I wrote my own little script. Takes share sheet or clipboard input string. If it's just a list of numbers, sums them. If there are arithmetic operators, evaluates the expression. If it's a simple one-variable expression, assumes it's an equation with the other side zero and feeds it to sympy to solve. If it's a one-variable equation, back to sympy. Should handle most basic day-to-day ticker-tape math needs, in only 75-ish lines of actual code.
https://gist.github.com/paultopia/16e69f9f72ad0a5000fa5b4575ddeee2
