Skip to content

Instantly share code, notes, and snippets.

@bensonk
Created April 21, 2010 21:20
Show Gist options
  • Save bensonk/374408 to your computer and use it in GitHub Desktop.
Save bensonk/374408 to your computer and use it in GitHub Desktop.
import os, sys
class Newquitter(object):
def __call__(s, v):
sys.exit(v)
def __repr__(s):
if os.isatty(sys.stdout.fileno()): sys.exit(0)
else: return "Use exit() or Ctrl-D (i.e. EOF) to exit"
__str__ = __repr__
exit = Newquitter()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment