Bottom Line: Once installed in Pythonista, these Python scripts will make it much easier to import a script from a URL.
Seems like everyone’s first Pythonista script is a way to import others’ Pythonista scripts more easily. Here’s my take.
I do most of my browsing on my Macbook, and I often use Messages.app to send URLs back and forth between my computer and my iOS devices. Once easy way for me to import a script into Pythonista is to message myself a pythonista:// URL that runs my import script and passes the external script URL as an argument. I use a TextExpander snippet abbreviated as .topythonista to make this even easier.
The Pythonista script (you’ll have to figure how to get this one in there) is pretty simple. Note that the script name is important for the pythonista:// URL to work (i.e. note the url-encoded version of the script name snippet below).
The TextExpander snippet I use is:
Once you have both of these in place, you can copy to your computer’s clipboard the (raw) URL to a Pythonista script (e.g. https://raw.github.com/jayhickey/Pythonista-Scripts/master/dropboxlogin.py), open an iMessage to yourself and type .topythonista… and the resulting mess should be clickable on your iOS device and result in a new script in Pythonista.
If you’re browsing from your iOS device instead of your computer, this slight variation works with a bookmarklet you can save in your mobile browser of choice. It also tries to pull in the script name, but may not succeed. I have no idea what I’m doing, so no promises.
Here is the bookmarklet. Pro-tip: to run from Chrome for iOS, navigate to the page with the (raw) script you’d like to import and start typing your bookmarklet name of choice (doesn’t matter what you name this it) into the omnibox, and tap the “suggestion.” If you try to use it by navigating through your saved bookmarks, it won’t work.
One last thing: if you have both an iPhone and iPad, it doesn’t take long to set up a script to sync your Pythonista scripts between your devices via Dropbox. Start with this thread. As a bonus, the scripts will also end up syncing to your Dropbox-connected computer, where you can edit them with whatever editor you’d like (though Pythonista’s editor is really good).