31 comments

[ 2.9 ms ] story [ 78.0 ms ] thread
Great stuff. When I taught intro programming to people with no programming background, I made a habit of doing live programming, in front of them. I let them see my mistakes, so they could see my debugging process, and of course, I tried to make it interactive, asking the class along the way how I should accomplish something.

I had to upload source code to a course webpage, which wasn't that onerous, but it also meant that I was only really going to upload one source file per lesson. I see this method of using IPython Notebook and Github as a great way of using technology to reduce to reduce friction to the point that the amount that is likely to be shared is much, much larger than when it all had to be done manually.

I've always done the live coding as well. It is so nice to not lose that live coding, and to be able to annotate it in a clean format.
Live coding is so important especially for beginners, I think it demystifies the whole process and shows them that there is nothing "magic" about programming, it's simply translating an idea about how to do something from your head into code.

I find that my students learn the most from interactive sessions where I live code in front of them and they ask questions, we change the code, re-run, etc.

Also debugging live in front of class is SO valuable for them. It not only shows them how to debug but it also shows them that everyone makes mistakes, and teaches them how to spot them.

If you are planning to use python 3 for teaching, you should keep away from IPython/this article. I just tried it with python 3.3. The readme says :

"Officially, IPython requires Python version 2.7, or 3.3 and above."

When you try to run IPython using python 3.3.0: File ".\IPython\config\application.py", line 288 print os.linesep.join(lines) ^ SyntaxError: invalid syntax

What did you try to do?

I am running Ubuntu 12.04, with several versions of Python installed including 2.7 and 3.3. I have the following packages installed: ipython, ipython-notebook, ipython3, and ipython3-notebook.

When I am developing most of these notebooks, I run 'ipython3 notebook'. When I need to make a cell using Python 2.7, I close the ipython3 server and run 'ipython notebook'.

Am I missing something?

Print in Python 3.3 uses parentheses (it's a function now) which might mean you have the wrong version installed.
Most distributions use two binaries: ipython (for python 2.x) and ipython3 specifically for python 3, unfortunately.
As others have noted, IPython itself works perfectly fine with Python 3.3 (I'm running it with 3.3.2 here). There must be something wrong with your configuration, or you might have some very old version of IPython (<0.11, released on 31 July 2011)
You might want to file a bug, report to one of the IPython mailing lists, ask a question on StackOverflow, ask a question in the IPython hipchat or IRC channel... really anything except for leaving rude comments on HN.
Feel free to ask for help on our mailing list. We regularly test IPython with python 3.3, and one of our core developers is a python-3 person, so he's using it day in, day out.

You most likely didn't run the installer correctly, and for some reason are trying to execute the python2 sources with python3.

If anyone wants, I'm happy to post a more explicit recipe for how to get multiple versions of Python and IPython running. It's easy enough to post right here.
I would like to know. For Windows and Ubuntu. I was never able to properly ipython notebook under 3.3 either.
This worked for me on Ubuntu 12.04:

First, add a ppa that has old and new versions of Python, and use that to install Python3.3:

    sudo apt-get install python-software-properties
    sudo add-apt-repository ppa:fkrull/deadsnakes
    sudo apt-get update
    sudo apt-get install python3.3
Now, install the correct versions of ipython, ipython-notebook, ipython3, and ipython3-notebook:

    sudo apt-get install ipython=0.13.2-1~ubuntu12.04.1
    sudo apt-get install ipython-notebook=0.13.2-1~ubuntu12.04.1
    sudo apt-get install ipython3=0.13.2-1~ubuntu12.04.1
    sudo apt-get install ipython3-notebook
Now, the command 'ipython notebook' should run your system's default version of Python. The command 'ipython3 notebook' should run Python3.3.

I test the current version of Python with:

    print(3/2)
If you're running Python 2, you'll see 1. If you're running Python 3, you'll see 1.5.

Hope that helps, and happy to help troubleshoot if it doesn't. I'll add this to the readme on the project page [1] when I get the chance.

[1] https://github.com/ehmatthes/intro_programming

thanks. this worked for me.
Does anyone know how to do this on windows? $ python -m IPython - first code line of github repo readme : https://github.com/ipython/ipython - on python 3.3 gives me an error.
For the time being, that bit of the README is misleading - you need to install IPython, because it relies on 2to3 running during setup.py. That will be fixed (by me!) for our next major release, due this winter.
I never use the default I interpreter on any system I want to maintain control and deployment consistency. I was using pythonbrew for a long time until I realized it was rotting on the vine. Now I use pyenv.
"If a student starts to outpace me, I can steer them into something more established such as Udacity or Coursera. These are the students who are likely to be successful in more independent learning settings."

Everything about what you do should be commended, but I outright give you a standing ovation for this point.

Yes.

Smartest teacher I ever had made the students grade each other's papers. Ends up being tutoring. Hardest grade I ever earned.

If I had programming instructors like this in college, let alone high school, I would have been a CS major full out.
One of the reasons I am hesitant (so far) to use IPython Notebook for teaching is that I worry about the longevity of the format. Maybe I'm a worrywart but my current preference is to use old (boring?) formats like html (via org-mode).
From my understanding, all IPython Notebook viewer does is convert a notebook to html, and serve the html.

So I am comfortable investing in this format, with the notion that I can dump to html and be no worse off than I was making blog posts or writing up tutorials.

On the other hand, IPython is 5+ years old(?), and it has some pretty strong backing and momentum. I have a good deal of confidence that it will be around for a while.

Edit: If you miss the comment below, IPython is almost 12 years old!

IPython is actually almost 12 years old, I started the project while a grad student in 2001.
We are extremely aware of this fact, and are working very, very hard to ensure that the format is a robust component of long-lived, archival-quality workflows.

We (in the IPython project) are interested in using it for capturing reproducible research workflows all the way up to the publication stage, so we're painfully aware of the importance of format stability, good conversion tools and support for early format migration forward.

We see many others investing their own time in using our tools, and we know we'd get burned at the stake if we make gratuitous changes that harm their workflows.

We do have some format changes in mind, but we've been "bunching them up" precisely so we can make format revisions only very rarely (we haven't done any in ~2 years), and with rock-solid support for conversions and migration.

Coincidentally, I'm currently working on a project to make IPython an (even) better tool for instruction and writing interactive 'textbooks', like what OP has done.

If anybody on here is an instructor who has a similar workflow, or is interested in trying something like this out, please drop me a line. We're in the middle of researching the most important areas for improvement, and we'd love to hear your feedback!

(EDIT: Email my username at Google's email service.)

I am interested. Having started to use this workflow in teaching programming, I find myself wishing again that educators had better dedicated tools. We need tools that allow teachers, in their core subject areas, to focus on building strong curriculum in that subject area.

Architects have CAD software, programmers have dedicated text editors and IDEs. Educators need curriculum development tools that let them focus on difficult and interesting pedagogical issues, not on formatting and version control issues.

How do I get in touch?

Please ping us on the ipython-dev mailing list; the core team is all made up of academics and we have a strong interest in educational uses (we're using it for our own courses), so it will be good to coordinate/share ideas on this front.
Have you see the Data Science course being presented at Harvard this semester? All of the lectures go through ipython notebooks and they turn in the assignments by submitting their notebooks. The url is http://cs109.org (with the relevant lectures at http://cs109.org/readings.php). Could be a source for additional information.
IPython Notebook is an incredible platform for interactive learning, and I used it as the basis of all examples in Mining the Social Web, 2nd Edition (O'Reilly - to go "final" tomorrow!)

My one complaint is that it's still quite a pain to get all of the necessary dependencies installed so that both IPython Notebook and all of its 3rd party package dependencies that might be used within the notebook "just works" across all supported platforms. However, that's not so much an IPython Notebook problem, per se, as it is just some of the pains in the larger Python ecosystem.

My recommendation to overcome the hurdle is to use Vagrant to take care of packaging IPython Notebook and all required dependencies so that you can provide a virtual machine featuring an IPython Notebook UI that "just works" once it boots up and you point your browser to localhost:8888.

I wrote about this at length if anyone is interested in thinking about the Vagrant+IPython Notebook combination a little bit more - http://miningthesocialweb.com/2013/08/24/reflections-on-auth... - and there's also a screencast illustrating how easy it can be to get it all running in the way I am describing.

In my opinion, there's no better way to reach the masses than with this combination of technologies. I hope to see more and more tech book writers jumping on board and treating the code as an OSS project with the book being the "premium support" for that OSS project. It's a win-win for everyone that way.

Installation sucks, we know. At present, we mostly point people towards Anaconda, or one of the other complete Python distros. That's not ideal if you already have a Python environment partly set up, because it gives you a whole new Python. But at the moment, it's the best of a bunch of bad options.