• Ahh, I see, I thought that you just replaced w with w+ and the context manager was already there. Sorry.

  • It was something stupid. Spelled the reference to the file Handel wrong.

    Thanks!!

  • 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!