[Discussion] Python on iOS State of The Art

After getting deeper into JavaScript I always miss pythons classes and modules. ((I say JS does not really have classes more beaten up objects … maybe I am to stupid to see them))

On iOS @drdrang wrote a good summary on the to competitors https://leancrew.com/all-this/2020/03/thoughts-on-ios-python/

I did a lot of scripting in Pythonista and started using Pyto.

As I see it, pyto is definitive the only candidate to use xcallbacks ((I lost 3 days during my holidays to setup the workaround for Pythonista via Objective C mapping last year…))

Are there any experiences with Pyto or with Pythonista especially in combining it with Drafts?

Drafts allows you to run Shortcuts, and Shortcuts can run Pyto scripts. Beyond that, I have no insight into using Python with Drafts.

I will say this: the current version of Pyto has a fatal bug in its editor. Today I was editing three separate files, comparing the three approaches to the same problem. At some point, I noticed that after editing File A, Files B and C contained the same source code as File A. Then I edited File B, and the contents of Files A and C changed. This terrible behavior stopped when I rebooted my iPad, but I don’t consider Pyto safe to use anymore. I sent a bug report and hope to hear back from the developer soon.

On the other hand, I believe the Pyto Run Code action in Shortcuts is still safe, as the source code is kept in Shortcuts, not Pyto.

Update I said above that the overwriting stopped when I rebooted, but a little more testing showed that the correct behavior was only temporary. It started overwriting again.

1 Like

Thanks for the information. That sounds very ugly.
I was thinking about using the pyto xcallback to create python augmented/powered Drafts actions.

Or even calling mdpre or md2pptx from @martinpacker. python-pptx installed fine.

If pyto is buggy I might have a look inside the source code on github.

It is sad that all Python options seem to get or stay worse.

Maybe the external RasberryPi as a python server is the best approach for today.

@drdrang Did your file or folder structure had any special structure? Like same file names in different folders?

1 Like

I started playing with Pyto.
No issues until now. note that I edited the scripts mainly in Drafts (with the upcoming syntax highlighting setupt, that might not be a bad idea).

I started a testing action group if anyone is interested.

To run the list.py in Pyto you have to create it via action first.

I find a split screen Pyto and Drafts a nice experiance for this actions.

The files that overwrote each other were in the same folder. Their first 10 or 11 characters were the same but then had 4-5 characters that distinguished them. Given that we are not running DOS, this shouldn’t be a problem.

Thanks. I want to look deeper into the matter on my own. This is to big a bug to ignore.

I am wondering if a simple python interpreter with PIP but without an IDE might not be a good way to go.

I would think md2pptx would fail in iOS as python-pptx has issues there. I would love to be wrong! mdpre should run as it has no python-pptx dependency.

As well as trans cousin mdpre does:

  • CSV to Markdown tables (with formatting extensions for md2pptx).
  • Variables

And a few other things I forget (as the author) :slight_smile: right now.

1 Like

I see some issues with md2pptx in my version (HTMLparser has to be renamed to html.parser)
But my investigation got side tracked by Pyto lack of documentation. After my investigation that resolved in the published action group we should be able to test further.

I still have to chase down a bug that @drdrang reported for sleeping well at night- file content should not be mixed up for a proper usage.

Pyto is far ahead of Pythonista in the field of xcallback, pip integration and the fact that is Python3 only.

If this it runs the way I fear, I would have to build my own version after purchasing a new mac…

1 Like

html.parser got done - and I thought I’d pushed it. Are you saying md2pptx works in Pyto? (I have it installed and would probably use it extensively if it did.)

give me a minute to pull the new code

I still have to figure out how to add input on iOS hence there is no stdin

maybe as sys.argv[2] or even with a click/typed command line interface would be golden.

Please open an issue for what you want. I was doing mdpre and md2pptx in stream mode - and that’s how I’ve set up my make files. But no reason why we couldn’t do something with arguments.

My syntax today is something like:

md2pptx test.pptx < test.md

But it could be something else if that’s all it takes to make it run with Pyto.

1 Like

Getting success on winOS with some modifications of the last version of your code (see Issues 7…11).

The Martin Template.pptx was created with the example code from the example file with README.md

Now I will start moving your template to look like my needed one.

1 Like

Just got an email from Pyto support saying that the file overwriting bug has been fixed in the latest release. Crossing my fingers.


The pyto editor component is a bit strange.

On the plus side it has a great pip integration and runs from any file location.

I think it may be used from another IDE that works on iOS Files.

Working Copy is quite potent as a editor and created by a great developer.

1 Like