Name:
[709] Jeff Rush
Member:
74 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
Name:
[709] Jeff Rush
Member:
74 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 ...
Our authors tell us that feedback from you is a big motivator. Please take a few moments to let them know what you think of their work.
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:
- python
- beginners
- programming
- beginner_programming
- graphics
- introduction
- software
- text
- tools
- demonstration
- look
- editor
- IDE
- like
- objects
- easy
- features
- systems
- commands
- available
- shell
- knowledge
- talks
- ipython
- demonstrating
- libraries
- interactive
- smd_multiplecreators
- keep
- frameworks
- power
- 5-minutes
- requirements
- restructuredtext
- coverage
- presentations
- buzzwords
Got any questions?
Get answers in the ShowMeDo Learners Google Group.
Video statistics:
- Video's rank shown in the most popular listing
- Video plays: 11541 (since July 30th)
- Plays in last week: 32
- Published: 72 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.
All comments excluding tick-boxed quick-comments
Super demo very clear and precise...
Thanks for exposing me to something I hadn't heard about. Could be very useful.
Thanks for exposing me to something I hadn't heard about. Could be very useful.
dude thanks for taking the time to make the ipython video
Thanks for the help
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
Thanks for the startup info. Very helpful - I'm a Matlab user trying to add Python to my repertoire.
great for a first survey - thx a lot
thank you ver much from maldive islands
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.
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!
Very informative, I hope the ipyhton learning curve is not to steep.
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.
Very clear and useful presentation.
I will now be following the rest of the series and trying out IPython myself.
Thanks!,
-Martin
Thanks for your help. I'm beginning to learn Bioinformatics and your videos are helpful.
Thanks a lot. Good pronunciation a attention to detail and pedagogical issues
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 :-)
Great introductory overview of IPython's major features. Thanks a lot!
Thanks for the quick intro to IPython.
super!
great intro to IPython.
nice
.........
ok
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.
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.
