From: Gergely Imreh Date: Fri, 19 Mar 2010 02:21:05 +0000 (+0800) Subject: tweepyshell: add support for IPython, with fallback to code.interact X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=39b1d77facf0dcb451ba76eb2186645266a4515e;p=tweepy.git tweepyshell: add support for IPython, with fallback to code.interact IPython is a much versatile interactive shell compared to code, use it's power if awailable. Signed-off-by: Gergely Imreh --- diff --git a/tweepyshell b/tweepyshell index eefb85a..6ba854d 100755 --- a/tweepyshell +++ b/tweepyshell @@ -2,7 +2,6 @@ import sys -import code from getpass import getpass from optparse import OptionParser import tweepy @@ -33,5 +32,14 @@ else: if options.debug: tweepy.debug() -code.interact('', local={'tweepy': tweepy, 'api': API(auth)}) +local_ns = {'tweepy': tweepy, 'api': API(auth)} +shellbanner = '' + +try: + import IPython + ipshell = IPython.Shell.IPShell(user_ns = local_ns) + ipshell.mainloop(sys_exit=1, banner = shellbanner) +except ImportError: + import code + code.interact(shellbanner, local = local_ns)