Name: [709] Jeff Rush
Member: 88 months
Authored: 15 videos
Description: Greetings. I'm the (former) Python Advocacy Coordinator and a strong supporter of screencasts. I'm also the organizer of the Dallas-Ft. Worth Pythoneers and was con chair for PyCon 2006 and 2007 in Dallas. I'm also an independent consultant and work in the areas of Python/Zope, embedded Linux s ...

Python and the Interactive Shell 'IPython' [ID:298] (1/4)

in series: 5-Minutes With Python

video tutorial by Jeff Rush, added 07/07

(Showmedo is undergoing major changes. To report any problems viewing the videos please email us and include browser and OS specifics. Cheers - Kyran.)

A slideshow introduction to the enhanced interactive shell name IPython. Superior to the default Python shell, IPython provides power object introspection features, easy access to operating system commands and integrates with your text editor.

If after viewing the slideshow, IPython looks like something you want to investigate further, check out my 5-talk series demonstrating how to use IPython.

The reStructuredText for these slides is available for study and reuse.

.. include:: <s5defs.txt>

============================================
 Python and the Interactive Shell 'IPython'
============================================

:Author: Jeff Rush
:Copyright: 2007 Tau Productions Inc.
:License: Creative Commons Attribution-ShareAlike 3.0
:Date: June 26, 2007
:Version: 1
:Series: 5-Minutes with Python

A 5-minute introduction to the enhanced interactive shell 'IPython'.  Superior
to the default Python shell, IPython provides power object introspection
features, easy access to operating system commands and text editor integration.

.. footer:: 5-Minutes with Python: Series

.. |CLICK| image:: /home/caster/themes/screencast-800x600/NextSlide.png

.. container:: handout

   Hello, my name is Jeff Rush and this talk is part of the "5-Minutes with
   Python" series.  In this brief talk I'll provide a comprehensive survey of
   the capabilities of the enhanced interactive shell known as "IPython".

   If it looks like something you might want to investigate further, there is
   a follow-up talk entitled "A Demonstration of the 'IPython' Interactive
   Shell" that gets more into the details using an interactive demonstration.


Roadmap to Talk
===============

.. container:: slide-display

   + `What is it and why use it?`
   + `How does it behave at the prompt?`
   + `Looking Up Information`
   + `Issuing System Commands`
   + `Manipulating Multiline Source`
   + `Instrumenting Your Source`
   + `For Further Investigation`

.. contents:: Table of Contents
   :class: handout

.. container:: handout

   |CLICK| In this talk I'll define what IPython is, why you might want to use
   it, and generally |CLICK| what mechanisms it adds to the interactive
   prompt.

   |CLICK| I'll cover the introspection capabilities it gives you,

   |CLICK| how it provides seamless access to the commands of your system
   shell, and |CLICK| integrates with your choice of text editors, allowing
   you to work in an iterative fashion.

   |CLICK| And I'll talk about how IPython can be hooked into your own
   programs, the execution profiling it offers and how you can add extra
   information to your tracebacks.

   |CLICK| I'll conclude with where to get IPython and what resources are
   available in that community.


What Is It?
===========

 + `an alternative to the default shell`
 + `non-GUI in nature`
 + `cross-platform and free`
 + `invocable from within programs`
    + `explicitly for code examination`
    + `implicitly upon uncaught exceptions`

.. container:: handout

   |CLICK| IPython is an alternative to the default Python shell,
   increasing your effectiveness at the interactive prompt while retaining its
   familiarity and keyboard friendliness.

   |CLICK| Like the default shell, it is a text-based, non-GUI method of
   interaction.  However it does have good support to run side-by-side with
   various 2-d and 3-d data plotting libraries and GUI toolkits.

   |CLICK| IPython runs on all the popular operating systems and it is free
   software so you can use it everywhere.

   |CLICK| It can be easily invoked from within your programs, either

   |CLICK| implicitly upon occurrence of an uncaught exception, or

   |CLICK| explicitly to put you into an interactive environment with the
   variable namespace current at that point.

   This makes IPython useful for both debugging and for those blended types of
   programs with heavy computation intermixed with exploration of the results,
   as in scientific data visualization.


Why Use It?
===========

 + `object introspection on steroids`
 + `access to the system command-shell`
 + `extensible into a domain-specific command language`
 + `can use your own text editor`

.. container:: handout

   |CLICK| IPython gives you the ability to powerfully introspect an object,
   showing its docstring, call signature, online help pages or source code.

   |CLICK| You can enter system commands, change directories and edit source
   files, while remaining within IPython.  This is especially nice for those
   platforms that lack a good command-line shell.

   |CLICK| IPython has what are called "magic" commands, which provide
   high-level functions that control the behavior of IPython itself.  You can
   define your own such commands and in combination with an input-filtering
   capability of IPython, construct a command language specific to the problem
   domain at hand.

   |CLICK| IPython is friendly to those of us who are particular to our text
   editors, moving source seamlessly back and forth between the editor and
   IPython while not forcing the use of a specific IDE text editor.


At the Prompt
=============

 + `caches the last N commands and their output`
 + `view, log, save, replay and edit this history`
 + `has a concept of namespaces`
 + `interprets names, by precedence`
    + `variables`
    + `magic commands`
    + `shell command aliases`

.. container:: handout

   |CLICK| At the prompt, IPython caches your most recent inputs, along with
   the output they generated.

   |CLICK| This command history is easily viewed, logged to a file and
   selectively saved into source files.  You can bring portions into your
   editor and have changes reevaluated into your session.  And you can quickly
   convert groups of frequently used commands into named macros.

   |CLICK| IPython, like the default Python shell, gives you access to the
   interactive namespace, for manipulating variables.  However it also
   provides easy ways to filter and display groups of variables, and to reset
   the namespace to its startup state.

   |CLICK| Because IPython accepts magic and system commands as well as source
   code, IPython uses rules to decide how to interpret a name when entered.

   |CLICK| If there is a variable with that name, it displays its value.

   |CLICK| Otherwise it consults a registry of "magic commands", essentially
   special names that invoke functions that manipulate your IPython session,
   navigate directories and manage files.

   |CLICK| And last it looks up the name in a list of aliases that map to
   commands issued to the underlying system shell.


Looking Things Up
=================

 + `input history and namespaces are searchable`
 + `tab completion`
    + `keywords, methods, variables, files`
 + `get brief and full info on any object`

.. container:: handout

   IPython gives you a number of ways to quickly look up information,
   almost eliminating the need to keep reference manuals at hand.

   |CLICK| The input history and variable namespaces are fully searchable by
   wildcard and type of object.

   |CLICK| IPython provides extensive tab-completion features, |CLICK|
   expanding names into variables, directories and filenames.  It understands
   nested namespaces in that you can type partial expressions like "classname
   dot <TAB>" and have it display the methods and attributes available to you.

   |CLICK| And you can query an object for information about its type, the
   namespace in which it is located, the source file from which it was loaded,
   and its docstring.  You can also display the source fragment that defined
   it, and its call signature if the object is callable.


Issuing System Commands
=======================

 + `! escape mechanism`
 + `aliases relate text to commands`
 + `command output into vars`
 + `var substitution into commands`
 + `directory navigation`
 + `background threading`

.. container:: handout

   |CLICK| Arbitrary system commands can be entered by prefixing them with the
   exclamation or *bang* symbol, as a common shell escape mechanism.

   |CLICK| Commands, perhaps with default arguments, can be aliased to a
   simple name, for easier use.

   |CLICK| Command output, optionally split on linebreaks or spaces, can be
   collected into Python variables,

   |CLICK| and in turn, variables can be substituted into commands.

   |CLICK| The system shell mechanism for IPython comes with a rich set of
   directory navigation commands, with bookmarking, history and a pushdown
   stack of visited places.  This makes working with complex frameworks across
   directory trees much easier.

   |CLICK| And you can cause arbitrary Python expressions to be executed in
   background threads and, with the extended version of IPython called
   IPython1, distributed across multiple CPU cores or host machines.


Manipulating Multiline Source
=============================

 + `line-oriented, not multiline`
 + `magic command: %edit`
    + `of files,` `objects,` `lines of input`
 + `automatic rentry of editor upon syntax error`
 + `simple source versioning`

.. container:: handout

   IPython is |CLICK| line-oriented -- while you can scroll back, change and
   rerun previous inputs, that would be awkward for definitions of functions
   or classes.

   |CLICK| IPython provides a magic "edit" command, that invokes your
   text editor on various kinds of targets.  Upon saving and exiting from your
   editor, the source is reevaluated into the current interactive namespace.

   |CLICK| You can pass to "edit" the name of a file you wish to change.

   |CLICK| But you can also pass an object reference.  IPython will look up
   the source file from which it came, invoke your editor on that file,
   and position you at the the definition.  Very cool.

   |CLICK| And you can pass the line numbers of previous inputs, as a range or
   list, and their text will loaded together into your editor.  Upon exit, each
   line will be re-evaluated into the current namespace.

   |CLICK| We've all made a quick change in our editor, only to find out at
   runtime that we've made a trivial syntax error.  IPython, upon reloading
   your source after an edit, can detect that syntax error and automatically
   take you back into the editor at the point it occurred.

   |CLICK| IPython provides a lightweight form of version control over edits.
   By retaining an historical copy of the result of each command, including
   edits, you can pass in a input line number representing a previous state,
   letting you revise and reload from that point.  Quite useful when teaching
   or demonstrating.


Instrumenting Your Source
=========================

 + `can be invoked from within your programs`
 + `uncaught exceptions enter the debugger`
 + `measure execution time of code fragments`
 + `integration with Python profiler`
 + `extended tracebacks with color`

.. container:: handout

   IPython provides ways to instrument your source with useful diagnostics.

   |CLICK| You can put calls in your program to start up an interactive
   session, giving you access to the variable namespace at that point.

   |CLICK| You can set IPython to enter the Python debugger upon the
   occurrence of an uncaught exception, letting you walk the stack frame and
   query variables.

   |CLICK| You can measure the CPU or wallclock execution time of code
   fragments, or |CLICK| run your code under the Python profiler for more
   detailed measurements.

   |CLICK| And you can set your preferred display of Python tracebacks,
   colorized for readability and with an extended mode that shows more
   information.


For Further Investigation
=========================

 + `http://ipython.scipy.org/moin/`
    + `users and developers mailing lists`
    + `online documentation`
    + `bug and feature request tracking system`
    + `articles, videos and presentations`
 + `Contact:`
    `Jeff Rush <jeff@taupro.com>`

.. container:: handout

   |CLICK| IPython is a mature, exciting project with a strong community.

   |CLICK| It has active mailing lists, separate for users and maintainers.

   |CLICK| A complete manual is available for browsing online or as a PDF
   document.

   |CLICK| And it has a tracking system for bug reports and feature requests.

   |CLICK| The project website provides magazine articles, video tutorials and
   slide presentations.

   I recommend you check it out.  There are other aspects of IPython I have
   not covered such as usage tips and techniques along with contributed
   extensions and profiles.

   |CLICK| |CLICK| Thanks for listening and look for the longer talk that
   demonstrates the actual use of IPython.

   These slides and script are available under the Creative Commons
   Attribute-ShareAlike license, for use in your own presentations.

..
   Local Variables:
   mode: rst
   mode: outline-minor
   End:

Got any questions?

Get answers in the ShowMeDo Learners Google Group.

Video statistics:

  • Video's rank shown in the most popular listing
  • Video plays: 12652 (since July 30th)
  • Plays in last week: 11
  • Published: 86 months ago

Thank-yous, questions and comments

If this video tutorial was helpful please take some time to say thank-you to the authors for their hard work. Feel free to ask questions. Let the author know why their video tutorial was useful - what are you learning about? Did the video tutorial save you time? Would you like to see more?

You may also want to see our ShowMeDo Google Group to speak to our active users and authors.

Your email address will not be published.

Show some quick comments >>








All comments excluding tick-boxed quick-comments

37. Anthony Riley Sun, 05 Sep 2010 18:57

Super demo very clear and precise...


36. interested Sun, 13 Jun 2010 13:17

Thanks for exposing me to something I hadn't heard about. Could be very useful.


35. interested Sun, 13 Jun 2010 13:17

Thanks for exposing me to something I hadn't heard about. Could be very useful.


34. benjamin pritchad Fri, 04 Jun 2010 21:04

dude thanks for taking the time to make the ipython video


33. BarryMaccaukner Wed, 12 May 2010 07:14

Thanks for the help


32. Marcus Uneson Fri, 26 Mar 2010 09:39

Comments refer to the entire set of python videos -- I still have a few left to watch, but so far they have all been excellent: concise, clear and to the point, easy to follow.

You are saving very much time for newcomers to python.

Thank you!


Great intro, thx!


that for that, very useful for someone like myself starting out with ipython


29. Mark Campanelli Mon, 18 Jan 2010 00:36

Thanks for the startup info. Very helpful - I'm a Matlab user trying to add Python to my repertoire.


28. anonymous Mon, 28 Dec 2009 06:32

great for a first survey - thx a lot


27. anonymous Sat, 19 Dec 2009 18:45

thank you ver much from maldive islands


26. anonymous Sun, 22 Nov 2009 12:09

I'm just getting into iPython, and I know I'm only scratching the surface. Thanks for letting me know what to look forward to.


25. anonymous Wed, 16 Sep 2009 12:26

Thank you for the video, Jeff.

I'm a Matlab user, between other expensive softwares. Yesterday I installed python because I want to move to the open source community. Today I discover ipython, and can not wait to install it!

Thanks!


24. anonymous Tue, 08 Sep 2009 16:18

Very informative, I hope the ipyhton learning curve is not to steep.


23. anonymous Tue, 08 Sep 2009 15:51

Hi Jeff,

I have seen snippets of ipython being mentioned before, but it wasn't until I saw your video that I took the plunge! Thanks for a great introduction.


22. anonymous Tue, 28 Jul 2009 22:44

Very clear and useful presentation.

I will now be following the rest of the series and trying out IPython myself.

Thanks!,

-Martin


21. anonymous Sat, 27 Jun 2009 15:25

Thanks for your help. I'm beginning to learn Bioinformatics and your videos are helpful.


20. anonymous Fri, 26 Jun 2009 06:46

Thanks a lot. Good pronunciation a attention to detail and pedagogical issues


19. anonymous Sat, 13 Jun 2009 15:23

Oh! I had no idea! I was under the impression that ipython was more or less nothing other than a way to run an interactive python shell without starting a terminal first... But this needs further investigation!

Oh and by the way - the sound quality was quite poor but not critically so :-)


18. anonymous Thu, 14 May 2009 06:02

Great introductory overview of IPython's major features. Thanks a lot!


17. anonymous Thu, 07 May 2009 18:53

Thanks for the quick intro to IPython.


16. anonymous Wed, 06 May 2009 07:48

super!


great intro to IPython.


14. anonymous Wed, 29 Apr 2009 08:23

nice


13. anonymous Mon, 13 Apr 2009 10:04

.........


12. anonymous Sun, 29 Mar 2009 22:49

ok


11. anonymous Thu, 25 Dec 2008 15:35

encouraged me to read the tutorials :D


For binding Python to C++ in a DLL, check out the "ctypes" module in the standard Python library, which lets you call entrypoints without writing any C/C++ code at all. If you need tighter binding, then look at the Boost and SIP toolsets, for wrapping C++ in Python.


9. anonymous Sun, 13 Apr 2008 18:29

Hey Jeff,

I'm looking for a tutorial about how to bind to Python in a C++ app, and possibly how to bind/load a C++ dll and call methods from Python.


Anon, I appreciate the feedback re difficulty to absorb. Perhaps you are right, for some people. My goal with 5-min talks, whether video or in writing, is to give information to the busy person who just wants some kind of executive summary on the features, advantages and tradeoffs of some piece of technology, rather than making them wade through a user manual. Busy people just won't do that, unless they are already aware that they need the tech. And of course, some of us are skilled at skimming user manuals to quickly evaluate new technology - I know I enjoy that, but many don't.

The screencast aspect can also be useful for those on the go who might just play the audio from a summarizing talk while jogging, in which case the talk must of necessity omit demonstrations and diagrams, and be usable without the video.

I will consider your comments and perhaps in the future attach a document to the 5-min talks for those who would prefer to read it.


7. anonymous Wed, 09 Jan 2008 20:55

Rather difficult to absorb. I believe this sort of pure-textual presentation is better handled and far easier to absorb in a printed document rather than a static "video" format of bulleted points. It might work in a classroom format, but not in this sort of "force-feeding" non-interactive format.

Neverthless, your efforts in this series are greatly appreciated.


Jeff - I have added this video to the IPython wiki (joining our other two series) and added a quote from Fernando on your longer series:

http://ipython.scipy.org/moin/Documentation

Ian.


Yes, this talk is part of the 5-Minutes with Python series in which we're going to briefly introduce those new to Python to what it can do. 5-minutes isn't much time so full demonstrations are difficult. Therefor we'll pair each 5-minute overview talk ('what is it and why should I care?') with one or more in-depth talks ('ok, so how do I actually use it?'), for each topic.


Anon - Jeff has also recorded an hour-long IPython demonstration that shows many interesting things...be patient for a few days and we'll have it online.

The demonstration is recorded inside IPython just as you have suggested, this video here is just to give a real-quick overview.

Ian.


3. anonymous Sat, 14 Jul 2007 18:33

Bravo! More!


2. anonymous Fri, 13 Jul 2007 18:27

Sorry, but this is boring. A screencast demonstrating they bullet points -- in *place* of the slides -- would be a million times better.


Very nice! Time to start using and learning IPython more seriously. I'm looking forward to watching more.


Showmedo is a peer-produced video-tutorials and screencasts site for free and open-source software (FOSS)- with the exception of some club videos, the large majority are free to watch and download.

how to help » about » faq »

Educating the Open-source Community With Showmedo

Although as important as the software it supports, education and documentation are relatively neglected in the Open-source world. Coders love to code, and explaining how best to use or improve the software tends to be deferred or even sidelined.

At Showmedo we believe the community can play a vital role here and also say thanks for the tools and software that make our lives easier. If you have a piece of software you love or a programming langugage you are enthusiastic about, why not make a screencast showing others how to use it? All the stuff you wish you'd been told, the tips, tricks, insights that would have saved you time and frustration.

Screencasting is easier than you think, and we're happy to help you. You can emailus for advice or just use some of the how-to screencasts on the site. This screencasting learning-pathis a good place to start.

Kudos and Thanks for Jeff

Learning Paths

This series lies on the following learning-paths. Learning-paths are a new initiative at Showmedo, to start structuring our content better. You can find out more here.

Content

Feedback

Showmedo's development is fairly rapid and bugs will inevitably creep in. If you have any problems please drop us a line using the contact address below. Likewise, any suggestions for improvements to the site are gratefully received.

feedback@showmedo.com