PYTHONSTARTUP Prompt History Revision 343037313465 (Tue Aug 31 2010 at 22:06) - Diff Link to this snippet: https://friendpaste.com/7l3KAmp42TDGeii5zd2DP Embed: manni perldoc borland colorful default murphy trac fruity autumn bw emacs pastie friendly Show line numbers Wrap lines 1234567891011121314151617181920# http://www.norvig.com/python-iaq.htmlh = [None] # historyclass Prompt: """ A prompt a history mechanism. From http://www.norvig.com/python-iaq.html """ def __init__(self, prompt='h[%d] >>> '): self.prompt = prompt def __str__(self): try: if _ not in h: h.append(_) except NameError: pass return self.prompt % len(h) def __radd__(self, other): return str(other) + str(self)