IPython is a much versatile interactive shell compared to code,
use it's power if awailable.
Signed-off-by: Gergely Imreh <imrehg@gmail.com>
import sys
-import code
from getpass import getpass
from optparse import OptionParser
import tweepy
if options.debug:
tweepy.debug()
-code.interact('<Tweepy shell>', local={'tweepy': tweepy, 'api': API(auth)})
+local_ns = {'tweepy': tweepy, 'api': API(auth)}
+shellbanner = '<Tweepy shell>'
+
+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)