What’s New in Pythonista
This page contains detailed information about changes in new versions of the Pythonista app.
- Support for both Python 3.5 and 2.7
- Integrated debugger with support for breakpoints and visual stack frame inspection
- Split-screen support on iPad Air 2 and later
- Theme editor for custom UI and syntax highlighting themes
- Integrated doctest support
- Integrated PEP-8 style checker
- Improved code completion with fuzzy matching and user-defined snippets
- Completely revamped photos module, including editable metadata, album creation, content editing, and more
Python 3 Suppport
- Pythonista now supports Python 3.5, in addition to 2.7. You can select the default interpreter in the settings. It’s also possible to override the default interpreter for individual scripts, using a “shebang” like #! python3 or #! python2 as the first line of a script. Alternatively, you can tap and hold the run button to test a script in the non-default Python version. To help you with migrating your scripts to Python 3, you can use the “Python 2 to 3” tool in the “wrench” menu.
- To learn more about the differences between Python 2.7 and 3.x, I recommend the following article (external link): The key differences between Python 2.7.x and Python 3.x with examples.
- If you also have Pythonista 2 installed, you can access your existing files through the special “Pythonista 2” folder in the script library. It is possible to move files from Pythonista 2 to Pythonista 3, but not vice-versa. You can disable the Pythonista 2 folder entirely from the settings.
- The interactive console uses the default interpreter version, but you can switch to the other interpreter by tapping the [2.7] or [3.5] button (depending on the current setting).
- When using the URL scheme to launch Pythonista, you can now use pythonista3:// instead of pythonista://. The old scheme is still supported, but its behavior is undefined if both Pythonista 2.x and 3.x are installed.
- On iPad Air 2 or later (including iPad Pro and iPad mini 4), Pythonista now fully supports the system-wide split-screen feature, so you can run another app next to Pythonista. Unfortunately, this also means that the orientations argument for ui.View.present() no longer works on devices that support split-screen, i.e. you can’t lock the orientation of a view to portrait or landscape. If auto-rotation isn’t disabled via Control Center, the app always auto-rotates. It is currently not possible to change this due to iOS limitations.
- Script shortcuts can now be added to the home screen from the editor actions (“wrench”) menu. This basically works by setting up a website that redirects to a pythonista3:// URL, so the actual shortcut is added from Safari. The Convert to PDF action has moved into the Share menu.
- Improved support for doctest tests – a new file template allows you to create a doctest file in Markdown format. There’s more information about this in the template itself. Doctest results are shown as annotations directly in the editor.
- You can now add your own templates to the “New File” menu. Simply add files to the Templates folder (in the Modules & Templates group).
- The view options for the script library (thumbnails, sort order) are now accesible directly in the library view (”...” button).
- Script shortcuts of the sharing extension can now be edited in the main app’s settings as well.
- Added a Sound Effects setting to disable keyboard clicks etc.
- Various “special” folders (standard library, site-packages) are now grouped under “Modules & Templates” in the script library. Note that this doesn’t change the location of these folders on disk, so the site-packages and Templates folders still appear directly under “Documents” in the “Move Files” dialog.
- There are now separate site-packages folders for the two interpreter versions. site-packages-2 is only used by Python 2.7, site-packages-3 only by 3.5. The old site-packages folder still exists as a fallback for both interpreters.
- Pythonista now includes a real debugger with support for breakpoints and visual stackframe inspection. This also replaces the traceback navigator, and enables more advanced “post-mortem” debugging when an exception occurs.
- To start breakpoint debugging, you have to add at least one breakpoint to your script (from the copy/paste menu). If a script contains breakpoints, tapping the run button will automatically offer a “Debug” option. The debugger is also shown in “post-mortem” mode when an unhandled exceptions occurs.
- The debugger UI appears as an overlay “window” on top of everything else, so that it’s possible to use it e.g. while a full-screen UI is presented. You can drag the debugger around on the screen if it gets in the way.
- To get more information about variables and stack frames, you can expand the debugger UI. The Variables tab shows you all local and global variables in the selected stack frame, and you can expand objects (using the triangle buttons) to show their attributes (or members, in case of sequences or dicts), which makes it possible to inspect nested data structures. Tapping on a variable name shows a string representation, similar to repr(var). For certain types of objects, a preview image is shown instead – this currently works for PIL.Image, ui.Image, ui.View, and ui.Path, and it’s indicated by an “eye” icon in the list.
- You can now define snippets in the settings to insert frequently-used pieces of (boilerplate) code more quickly. When you set an abbreviation for a snippet, it shows up in the code completion suggestions. You can also select from a list of snippets in the editor using the copy/paste menu (with an empty selection) or the Cmd+D keyboard shortcut. Note: Snippets are only supported in Python files.
- The Convert Tabs action is now undoable, and the confirmation dialog has a new option to open the indentation settings.
- Code completions can now be suggested based on fuzzy matching, e.g. typing “rage” also suggests “range()” (fuzzy-matched completions are always shown after precise matches).
- When using an external (Bluetooth) keyboard, code completions can now be selected with the up/down arrow keys.
- A new Cmd+L (or Ctrl+6) keyboard shortcut shows the current file’s outline (while editing) – The up/down arrow keys and return can be used to navigate to a different function without touching the screen.
- New Cmd+Shift+B shortcut for adding/removing breakpoints.
- When text is selected, pressing the tab key will now indent the selected line(s) instead of replacing the selected text with a tab. Shift-tab can be used to unindent on an external keyboard. On the on-screen keyboard, you can tap and hold the tab key for an unindent option. Indentation options are no longer shown in the copy/paste menu by default, but you can re-enable them in the settings (under “Keyboard & Typing”).
- The color picker (in the UI editor and asset picker) now allows entering arbitrary hex values by tapping on the color swatch.
- Integrated PEP8 style checker: You can check a script by tapping and holding the ▷ (run) button. Various options for customizing the rules are available in the settings. Issues are highlighted directly in the editor.
- Integrated pyflakes static analyzer: Similar to the PEP8 style checker, you can invoke this by tapping and holding the ▷ (run) button. The analyzer can find unused imports, undefined variables, and similar issues, which are also highlighted directly in the editor.
- When running a script with arguments (by tapping and holding the run button), the arguments are now saved for each script individually. When the current script has any saved arguments, they are also used for running the script normally (i.e. by just tapping the run button). The icon of the run button changes slightly to indicate whether there are arguments for the current script.
- Line numbers can optionally be shown on iPhone as well (line numbers were previously iPad-only).
- On iPhone, the “show tabs” button is now at the bottom of the screen (or above the keyboard), so that the editor actions (“wrench”) menu is more easily accessible in the main toolbar.
- The search bar in the editor now uses the same extra keyboard row as the editor itself.
- New “Line Length Warning” option (under Indentation & Coding Style). When enabled, the end of long lines is highlighted. The maximum line length can be customized (79 by default).
- Improved console prompt: The text input area now expands automatically for multi-line statements (e.g. function definitions, loops). The code completion behavior is also more consistent between the editor and console now (e.g. the tab key inserts the first suggestion).
- Showing images in the console has been improved substantially. A single tap on an image now opens it in a zoomable full-screen view. The sizing of image containers also matches the aspect ratio of the shown images more closely, especially when the console is in the more compact “docked” mode.
- The photos module has been completely revamped, and allows far more advanced access to the iOS photo library, including editable metadata, album creation, and content editing. Please see the photos module docs for details.
- Views that are presented in ‘panel’ style can be closed programmatically now (the ui.View.close() method was previously ignored for this presentation style).
- The ui.TableView initializer supports keyword arguments now (same as other ui.View subclasses)
- ui.WebView can now load non-https pages in the app extension.
- ui.WebView.load_url now treats absolute file paths like file URLs (so you don’t have to construct a file:// URL for loading local files).
- copy.copy() now works correctly for geometry types (ui.Point, ui.Size, ui.Rect).
- The behavior of sys.exit() has changed: Registered atexit handlers are called, but nothing else happens (previous versions printed the exit code to the console). If you really want to exit the app, use os._exit().
- The editor no longer strips trailing blank lines when saving.
- The console has (limited) support for the \b and \r control characters now. The most common use case would be simple progress displays that overwrite the last line that was printed. Note that (unlike in a real terminal) these control characters only have an effect within a single string. Printing should also be a bit faster, and a couple of issues with console.set_color() and console.write_link() are fixed.
- When a script is running in the background for longer than iOS allows (about 3-4 minutes), the app should usually be suspended now (previously, it was killed immediately).
- It’s now possible to open folders in the library using the URL scheme. The syntax is the same as for opening files (pythonista3://some/path?action=open).
- Pythonista is now compatible with all iOS screen sizes – from iPhone 4 to iPad Pro, and everything in-between.
- For larger projects, you can now use multiple editor tabs to switch between related files more quickly.
- The Pythonista app extension allows you to run Python scripts directly within other apps, using the standard iOS share sheet. Depending on the context, you can use the new appex module to access data that was passed to the share sheet, e.g. images in the Photos app, URLs in Safari, text in Notes, etc. The app extension also provides an interactive console and a basic code editor for small tweaks.
- New and refined color themes are available in the settings; selecting a different theme now changes the entire app’s UI instead of just syntax highlighting.
- Additional templates are available in the improved “new file” menu. You can also import photos from your camera roll as image files there.
- The console’s interactive prompt is now syntax-highlighted, and provides better support for Bluetooth keyboards (you can use the up/down keys to navigate the command history).
- You can now read the (pure Python) source code of the included standard library (and third-party modules) directly in the app. Simply enable the “Show Standard Library” setting if you’re interested in looking “under the hood”.
- The UI editor contains a much improved inspector panel, undo/redo support, the possibility to set custom attributes, and a lot of other refinements.
- The new traceback navigator allows you to get a lot more information about errors in your programs. When an exception occurs, a brief summary is shown at the top of the screen, and the line where the exception occurred is highlighted in the editor. By tapping on the exception summary, you can navigate the entire traceback, even if the source of the exception is in a different file. You can also tap the <... marker in the editor to inspect variable values in the selected stack frame.
- The editor actions (“wrench”) menu has been improved significantly. You can now assign custom icons and colors to your script shortcuts. It’s also possible to invoke the standard iOS share sheet from the actions menu. If you have an iPhone 6s or 6s Plus (with 3D Touch), you can launch shortcuts directly from the homescreen by pressing the Pythonista icon.
- The improved asset picker ([+] button) contains more free image and sound effect collections that can be used with the scene, ui, and sound modules. The UI for opening the asset picker is also consistent between iPad and iPhone now.
- When the cursor is inside a color string (e.g. ‘#ff0000’ or ‘red’) or built-in image name, a preview overlay is shown automatically. You can also tap the preview overlay to select a different color or image.
- The new Highlight All option in the copy/paste menu allows you to quickly find all occurrences of a word (e.g. variable name), without typing anything in the search bar.
- You can adjust the indentation of a selected block of code more easily with the new ⇥ Indent menu items (in the copy/paste menu).
- iPad only: The extended keyboard has a more compact layout by default. If you prefer a larger keyboard with an additional number row, you can enable this in the settings.
Python / Modules
- The completely revamped scene module gives you a lot more possibilities for building 2D games and animations in Pythonista. You can even use custom OpenGL fragment shaders. Lots of new sample code and a tutorial for building a simple game are available in the included Examples folder.
- The ctypes module from the standard library is finally available in Pythonista, and the custom objc_util module uses this as the foundation for an Objective-C bridge that makes it possible to call native APIs using familiar Python syntax. A few sample scripts are included in the Examples folder.
- You can customize the startup process of the Python interpreter by creating a file named “pythonista_startup.py” in the site-packages folder. When the app is launched, the interpreter will execute this module, so that all variables/functions/classes in the script become available globally. A common use case might be from math import * (if you want to use the console as a calculator). Note: If Pythonista becomes unusable due to a misbehaving startup script, you can launch the app in a “clean” state by entering pythonista:// in Safari’s address field.
- You can no longer use the “Open in...” menu from other apps to open files in Pythonista. This change was made in order to comply with Apple’s app review guidelines.
- Xcode export is currently not available from within the app. I’m working on a way to create Xcode projects from Pythonista scripts on a Mac instead; details will be available on the Pythonista website soon.
- Smarter code completion – in situations that the old completion system couldn’t handle, Pythonista is now using the jedi library. This applies to things like instance members, where the type of the object can be inferred. The extended code completion can be somewhat slow, depending on your device generation and the size of modules you’re working with. It should get faster over time, as caches are built, and the old completion system continues to work while you’re waiting for jedi results, but in case you find this impacting the overall performance of the app and your scripts, you can disable extended completion separately in the settings.
- The documentation is now shown in the same panel as the console (this also applies to the built-in web browser used by the webbrowser module).
- The keyboard shortcut for switching between editor and console is now Cmd+J instead of Cmd+<Space> (the previous shortcut conflicted with switching the keyboard language).
- The integrated documentation has a new look.
- User-created modules are now reloaded automatically when running a script.
- New site-packages folder that is included in the default sys.path (this is a good location for shared modules that you want to import in scripts across different folders). Please note that the aforementioned automatic reloading doesn’t apply to modules in this folder (in order to improve performance).
Python / Modules
- Integrated numpy and matplotlib.
- New ui module for creating native user interfaces on iOS, including an integrated UI editor.
- New motion module for accessing the device’s motion sensors (accelerometer, gyroscope, magnetometer).
- The notification module has a new notification.set_badge() method.
- Various improvements in the photos module, especially the photos.pick_image() function (new keyword arguments for multiple selection, including metadata, and returning raw data instead of decoded images)
- Updated various modules to the latest PyPI versions (bottle: 0.11.4 → 0.12.5, bs4: 4.1.3 → 4.3.2, feedparser: 5.1.2 → 5.1.3, html5lib: 0.95-dev → 0.999, markdown2: 2.1.0 → 2.2.1, paramiko: 18.104.22.168 → 1.13.0, pygments: 1.5 → 1.6, pyparsing: 1.5.7 → 2.0.1, requests: 1.2.2 → 2.2.1)
- Fixed incorrect behavior of up/down arrow keys (on hardware keyboards) after changing the selection via tap.
- Fixed a bug that caused indentation errors to be silently ignored (the script failed to run, but no error message was shown).
- Fixed a potential crash with photos.get_metadata on Chinese iPhones.
- Fixed a potential crash when the recursion limit was exceeded.
- The contacts module can now retrieve the birthday of a person if the year isn’t set (the year component will be in the distant past in this case); this previously raised an internal exception.
- Complete UI overhaul for iOS 7.
- The interpreter is now based on Python 2.7.5.
- There’s a new setting to use spaces (“soft tabs”) instead of tab characters for indentation. The new “Convert Indentation...” action can be used to change the indentation of an existing script to the current setting.
- The action menu is now directly editable, without having to open the settings. It is also possible to add scripts in folders as actions, and actions can have custom command-line arguments.
- Non-Python files are now visible in the script library. Plain text files can be edited, for other files, a QuickLook preview is shown.
- All scripts are now run in the same interpreter that is also used for the interactive prompt. This makes the console a lot more useful because you can now define functions, classes, etc. in a script and experiment with them directly, without having to use execfile(). It also makes starting scripts a lot faster in most cases because imports are cached. By default, all global variables are cleared before running a script, but there’s a new setting to control that behavior in the “Interpreter Options” section. If you want to completely reset the interpreter, you can do that by tapping and holding the “Clear” button in the console.
- There’s a new option to always clear the console before running a script (in the “Interpreter Options” section of the settings).
- Tapping and holding an auto-completion suggestion now shows a help popover (iPad only).
- Improved support for (external) keyboard shortcuts – Shortcuts now use the Command key instead of Option/Alt, and there’s a new shortcut to clear the console output (Command + K).
- Scripts are auto-saved more often.
- Fixed: Using an action URL with the notification module did not work correctly if Pythonista was not already running in the background when the notification was activated.
- Fixed: Certain types of syntax errors (e.g. “‘break’ outside loop”) weren’t shown.
- Fixed: Exporting the entire script library also exports subfolders now.
- Fixed: CJK string encodings should work properly now.
- Fixed: After using the canvas module, the console sometimes showed up, even though there was no output.
Python / Modules
- New contacts module to access the iOS address book database.
- New location module (access to GPS data and geocoding services)
- New speech module (text-to-speech synthesis).
- Most standard library modules have been updated as part of the transition to Python 2.7.5.
- The console module has a new console.quicklook() function for previewing many types of files (e.g. PDF and Office documents, but also images and media files).
- The sound.play_effect() function now supports local files (in addition to the built-in effects). It also has two new optional parameters for volume and pitch, and it’s possible to stop individual sound effects with the sound.stop_effect() function.
- New webbrowser.add_to_reading_list() function to add URLs to Safari’s Reading List.
- The standard library is now included as compiled bytecode (.pyc), in addition to the source code. This should improve performance in a lot of cases.
- The requests module has been updated to the latest version.
- There’s a new anti_alias option in the scene.run() function (the equivalent setting is gone).
Added Modules from the Standard Library
- Redesigned library view.
- It’s now possible to organize your scripts in folders.
- Triple-quoted strings are now highlighted correctly in the editor.
- Wrapped lines are indented and marked with a triangle symbol in the editor.
- Scripts can now continue to run for up to 10 minutes in the background. This is particularly useful for things like local web servers because it’s now possible to access them from Safari. Please note that sound effects will not be played while the app is in the background (but you can use the new notification module for that).
- New sample code: Image Warp and Markdown Conversion
Python / Modules
- The new photos module allows you to access images in your camera roll and manipulate them using the PIL (Python Imaging Library) module.
- The new notification module allows you to schedule notifications that are shown in Notification Center.
- markdown2 provides an alternative to the markdown module that was added in 1.2.
Changes in Existing Modules
- New scene.unload_image() function that can be used to remove dynamically generated images (loaded via scene.load_pil_image()) from the cache.
- Additional parameters in the scene.image() function allow to draw partial images (e.g. for things like sliding puzzles).
- New image_quad() function to draw quadrangular portions of an image. It is also possible to use this to distort images. See the new Image Warp sample script for an example.
- It’s now possible to use webbrowser.open() to open http or https URLs in Safari instead of the built-in browser. Simply replace http:// with safari-http:// in the URL (safari-https:// for https URLs).
Added Modules from the Standard Library
- Added pyexpat (this also fixes issues with some other modules, like plistlib)
- Added xmlrpclib
- Fixed issues in the scene module with auto-rotation on iOS 6.
General / UI
- Support for the larger screen of the iPhone 5.
- We now have a community forum, come say hello!
- There is a new line spacing setting for the editor.
- iPad: Some keys on the extended keyboard can be used to enter different characters by touching and holding them. These keys are marked with a gray corner. You can also swipe up on such a key to enter the first alternate key (e.g. swipe up on the forward-slash key to insert a backslash).
- You can now run scripts with command-line arguments. Just touch and hold the run button.
- Pythonista now has a URL scheme for opening and running scripts that are in your library. See The Pythonista URL Scheme for details.
- The prompt history no longer adds the same command multiple times if you repeat it.
- Added a new image collection of test images from the USC-SIPI Image Database.
- New font option for the editor: Adobe Source Code Pro
- The “High Resolution” setting for retina screens is gone (it is now always enabled).
- The color picker now has an option to insert HTML-style colors. This is primarily meant for the new PIL module, but it has other uses as well.
- The gesture recognition on the extended keyboard is a bit less sensitive, so that it doesn’t interpret very small movements as gestures (which could sometimes interfere with tapping keys).
- Error markers in the editor now include the type of the exception.
- Some additional shortcuts are available to use with external hardware keyboards (see Using External Keyboards for details)
Python / Modules
- bs4 (BeautifulSoup 4)
- PIL (Python Imaging Library) – Have a look at the new “Image Effects” sample code to see how PIL is integrated with Pythonista.
Changes in Existing Modules
- console module
- There is a new console.show_image() function to
display images in the text output area. This is used internally
by the Image.show() method in the PIL (Python Imaging
Library) module that was also added in this release.
- There are two new functions for controlling the network activity indicator
(“spinner”) in the status bar – console.show_activity() and
- scene module
- You can now load images from regular image files with the
scene.load_image_file() function. It’s also possible to load images
created with PIL (Python Imaging Library), using the
- You can now get at the underlying image files of built-in images using
the scene.get_image_path() function.
- The new scene.line() function can be used to draw simple lines
between two points.
- The new scene.get_screen_scale() function allows you to detect
programmatically if your script is running on a device with a retina
- webbrowser module
- The webbrowser.open() function has a new, optional modal parameter
that blocks the script until the Done button is tapped in the browser.
Additionally, there is an optional stop_when_done parameter that can
be used to stop a script automatically when the Done button is tapped
in the browser.
Added Modules from the Standard Library
- On the iPad you can now view the current documentation page’s table of contents to make navigating in long documents easier.
- The documentation now uses DejaVuSansMono instead of Courier for code.
- Basic documentation for the requests module is now included. The module itself was already available in version 1.1, but there was no documentation.
- Fixed an issue with big numbers not automatically being converted to long integers (something like 2 ** 100 should now work correctly without having to append L explicitly).
- The __file__ variable is now correctly set when you run a script.
- Fixed issues with pasted text that contains unicode space characters.
- Fixed a bug in console.password_alert() that caused it to always return None.
- Some images in the Typicons library weren’t centered properly, this has been fixed.
- Fixed an issue on iOS 6 that caused the documentation viewer to start with a blank page.
- The clipboard module can handle unicode now.
- time.strptime() works correctly now.
- editor.make_new_file() no longer appends a numeric suffix when it’s not needed (i.e. when no file with the given name exists).
- Fixed a crash that occurred when canceling the console’s “Copy Text Output” dialog.
General / UI
- Pythonista is now a universal app that runs on all iOS devices!
- The editor has a new search feature.
- The editor itself is now scriptable (via the new editor module) and custom scripts can be added to the new actions menu for quick access.
- Scripts can now be exported from the editor, optionally as Xcode projects that build standalone iOS apps (please note that in order to run standalone apps on an actual device you need to be a paying member of Apple’s iOS developer program).
- The script library has a new list mode (in the iPhone version, the thumbnail view is not present and this is the only view mode).
- The script library can be sorted by date instead of by name.
- The top toolbar that was shown for scenes created with the scene module is gone, so that there is more room for drawing. Instead, there is only a small overlay button in the top-right corner to close a scene.
- The Typicons set of monochrome icons is now available to use in the scene and canvas modules.
Python / Modules
The scene.Scene class has additional callbacks for when the home button is pressed (scene.Scene.pause()) or the app resumes from the background (scene.Scene.resume()).
Scenes can now optionally auto-rotate to different device orientations (see scene.Scene.should_rotate() for more information).
- The console module provides some new functions:
- console.secure_input() – A drop-in replacement for the built-in raw_input that is suitable for entering passwords (the text being entered is hidden).
- console.alert() – Allows you to show simple message boxes with up to three custom buttons, e.g. to ask the user for confirmation without requiring keyboard input.
- There are several other alert types that allow you to present alerts with text and/or password fields.
The new keychain module provides simple functions for securely storing passwords.
The new editor module allows you to script Pythonista’s text editor itself, have a look at its documentation for some interesting examples.
- More modules from the Standard Library are included:
The Documents directory (where scripts are stored) is now the default directory in the interactive prompt,
so that it’s easier to write files without giving an absolute path.
The console output and text drawing functions in the scene module support unicode now.
The webbrowser now opens web pages in an in-app browser view instead of Safari.
The canvas module has new functions for drawing text.
- All code samples now have “Copy” and “Open in Editor” buttons attached to them for quickly trying out things you read about.
- There is a new “Using Pythonista” page that provides an illustrated overview of the UI.
- Text in the documentation is now hyphenated for better readability, especially on the iPhone.
- The canvas documentation contains more details and examples.
- The search suggestions in the documentation now show modules first.
- The chapter “Using the Python Interpreter” in the Python language tutorial is no longer included. Most of it only applies to other platforms and it seems to have caused some confusion. If you’re interested in this chapter, you can read it here. The same applies to “Interactive Input Editing and History Substitution” which can be found here.
- A crash that could occur when holding down the backspace key has been fixed.
- Switching from the quick help popover to the full documentation should be more reliable.
- os.getcwd() should now work correctly.
- Entering a blank line when using raw_input no longer raises an EOFError.
- Drawing images with the canvas module now works correctly if no other drawing functions were used before.
This is the initial release of Pythonista on the App Store.