What’s New in Pythonista
This page contains detailed information about changes in new versions of the Pythonista app.
- 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: 220.127.116.11 → 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.