old_contents: if 'pythonrc_guard' not in globals():
      import os, sys, re, pdb
      from subprocess import *
      from pprint import *
  
      def pdir(obj):
          pprint(dir(obj))
  
      def attrs(obj):
          d = {}
          for name in dir(obj):
              d[name] = getattr(obj, name)
          pprint(d)
  
      def reloadall():
          "Reload all modules"
          for x in list(sys.modules):
              if x != '__main__' and type(sys.modules[x]) == type(sys):
                  reload(sys.modules[x])
  
      # enable syntax completion
      try:
          import readline
      except ImportError:
          print("Module readline not available.")
      else:
          import rlcompleter
          readline.parse_and_bind("tab: complete")
  
  
      # set color prompt, see http://ascii-table.com/ansi-escape-sequences.php
      sys.ps1 = '\001\033[32m\002>>>\001\033[0m\002 '
      sys.ps2 = '\001\033[32m\002...\001\033[0m\002 '
  
      # read local .pythonrc.py
      if os.path.exists('.pythonrc.py'):
          pythonrc_guard = None
          with open('.pythonrc.py') as f:
              exec(f.read())
          del pythonrc_guard
  
  
new_contents: if 'pythonrc_guard' not in globals():
      import os, sys, re, pdb
      from subprocess import *
      from pprint import *
  
      def pdir(obj):
          pprint(dir(obj))
  
      def attrs(obj):
          d = {}
          for name in dir(obj):
              d[name] = getattr(obj, name)
          pprint(d)
  
      def reloadall():
          """Reload all modules"""
          for x in list(sys.modules):
              if x != '__main__' and type(sys.modules[x]) == type(sys):
                  reload(sys.modules[x])
  
      # enable syntax completion
      def f():
          try:
              import readline
          except ImportError:
              print('Module readline not available.')
          else:
              import atexit, rlcompleter
  
              readline.parse_and_bind('tab: complete')
              path = os.path.expanduser('~/.pyhistory')
  
              atexit.register(lambda: readline.write_history_file(path))
  
              if os.path.exists(path):
                  readline.read_history_file(path)
      f()
      del f
  
      # set color prompt, see http://ascii-table.com/ansi-escape-sequences.php
      sys.ps1 = '\001\033[32m\002>>>\001\033[0m\002 '
      sys.ps2 = '\001\033[32m\002...\001\033[0m\002 '
  
      # read local .pythonrc.py
      if os.path.exists('.pythonrc.py'):
          pythonrc_guard = None
          with open('.pythonrc.py') as f:
              exec(f.read())
          del pythonrc_guard
  
  
subject: add command history to .pythonrc