Interactive Python shell with IPython
One nice thing about Python as compared to some other scripting languages, is that it has a shell that enables us to test our Python script on the fly without needing to write a script file first
It’s nice and all that, but when you’re too used to IDEs which has features such as auto completion etcetera, you’ll feel like something is not right about the default python shell.
That changes when I come to IPython, one of the few other enhanced Python shell. The one feature I like most is the auto complete feature, which among other by using it I don’t need to remember module names, and at the same time would list and try Python modules that I’ve never heard of.
In Ubuntu, or debian in general, the package is called ipython, and to install it just;
shakir@herugrim ~ $ sudo apt-get install ipython
Can you spot the differences between this
shakir@herugrim ~ $ python Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import command Traceback (most recent call last): File "", line 1, in ImportError: No module named command >>> import commands >>> status, output = commands.getoutputstatus ('ls') Traceback (most recent call last): File " ", line 1, in AttributeError: 'module' object has no attribute 'getoutputstatus' >>> status, output = commands.getstatusoutput ('ls') >>> print output Desktop Documents Music Photos >>> shakir@herugrim ~ $
and this?
shakir@herugrim ~ $ ipython Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32) Type "copyright", "credits" or "license" for more information. IPython 0.8.1 -- An enhanced Interactive Python. ? -> Introduction to IPython's features. %magic -> Information about IPython's 'magic' % functions. help -> Python's own help system. object? -> Details about 'object'. ?object also works, ?? prints more. In [1]: import command ---------------------------------------------------------------------------Traceback (most recent call last) /home/shakir/ in () : No module named command In [2]: import commands In [3]: status, output = commands. commands.__all__ commands.__hash__ commands.__setattr__ commands.__class__ commands.__init__ commands.__str__ commands.__delattr__ commands.__name__ commands.getoutput commands.__dict__ commands.__new__ commands.getstatus commands.__doc__ commands.__reduce__ commands.getstatusoutput commands.__file__ commands.__reduce_ex__ commands.mk2arg commands.__getattribute__ commands.__repr__ commands.mkarg In [3]: status, output = commands.gets commands.getstatus commands.getstatusoutput In [3]: status, output = commands.getstatusoutput('ls') In [4]: print output Desktop Documents Music Photos In [5]: Do you really want to exit ([y]/n)? y shakir@herugrim ~ $
I hope you can guess when did I press the [tab] key
Connect with me
What I'm Doing (via twitter)...
- is applying for US visa. The website is not helping at all http://twitpic.com/16hvxp 1 week ago
- @abumuaaz want to focus on my wireless project (yes, I get paid for that) and some development work. Ada job to pass ka? :) in reply to abumuaaz 1 week ago
- is running 'sudo dd if=/dev/zero of=/dev/sda' on his laptop. Will it work, my computer forensic friends? 1 week ago
- is on his first day of being jobless, hahaha. 1 week ago
- finished reading Crowdsourcing: Why the Power of the Crowd Is Driving the Future of Business, in 32 hours. Next, Wikinomics. 1 week ago
- is on his way to island hopping. Woohoo! 1 week ago
- is leaving on a jetplane, don't know when he'll be back again... 2 weeks ago
- missed his flight to KK. Will need to take the first flight tomorrow and pray he'll make it for his 9am meeting. 2 weeks ago
- More updates...











