Python notes

 
  • Python shell history
    import readline
    readline.write_history_file("my_history.txt")

    taken from tips.webdesign10.com
  • reverse array index a[:,::-1]
  • dump any data object to binary file and reload: pickle module
    import pickle
    f = open("filename", "wb")
    pickle.dump(somedata, f)
    f.close()
    f = open("filename", "rb")
    somedata = pickle.load(f)
    f.close()
    taken from python.org mailing list