• keychain.setpassword is a Python function in the keychain module provided by Pythonista. You need to use it in Pythonista's Python console, not in Stash. (Also don't forget to run import keychain first, so you can use the keychain module in the console.)

  • The question is a little different, since he already has written to the console, and NOW wants to save it. Technically this can be done in 3 lines, so qualifies for ccc's ten lines or less....
    though i broke up the long string of method calls onto multiple lines to keep some semblance of readability.

    This is my save_session script which appends to a command history file ( making it easier to convert an interactive session into a real script), and writes the current console output to a new file. Feel free to adapt to your own needs.

    from objc_util import UIApplication from time import ctime # save history with open('history.py','a') as f: f.write(ctime()+'\n') f.write( '\n'.join([str(h) for h in UIApplication.sharedApplication().keyWindow(). rootViewController().accessoryViewController(). consoleViewController().history() ])+'\n') #save console output with open('console_history.txt','w') as f: f.write(ctime()+'\n') f.write(str( UIApplication.sharedApplication(). keyWindow().rootViewController(). accessoryViewController().consoleViewController(). consoleOutputTextView().text() ))
Internal error.

Oops! Looks like something went wrong!