econchick / new-coder

New Coder tutorials
zlib License
597 stars 392 forks source link

Put all tutorials in IPython notebooks #126

Open mathonsunday opened 10 years ago

mathonsunday commented 10 years ago

This can be broken down into separate issues based on who volunteers to do what.

caynan commented 10 years ago

@mathonsunday I could do this, but could you please elaborate on how do you think will be a good way to represent this on iPython notebook? Should I basically put the text and codes, as they're on the original tutorial?

econchick commented 10 years ago

@mathonsunday just documented this for me, it is actually my plan to do this.

If you have some energy and time @caynan to do this, let's talk, maybe on IRC or something. We can hash out what it'd look like on ipython.

I'm roguelynn on Freenode, usually hanging around during the day in the empty #newcoder channel.

econchick commented 9 years ago

So, @caynan, to answer your question in the other thread:

Ideally, I would like to have two sets of notebooks for each tutorial - one for the tutorial language (from the website), and one for the actual tutorial code.

I made a sample IPyNB of one of the tutorials (the language, not the actual source code) here.

One main issue - the code will not easily run within the notebook, especially if there are other files we're importing (e.g. the scrape tutorial).

You can write the python code with Markdown and Pygments in the notebook, like so:

    ```python
    def foobar(baz):
        pass


but that defeats the purpose of making notebooks out of the tutorial.

@caynan I'll let you run with the idea; perhaps you can try to create a set of NBs for one tutorial and let me take a look?
merwok commented 9 years ago

Will it be practical to link from one notebook to the other, and easy to use?

I don’t have much experience with notebooks, but I thought that their point was to allow free mixing of prose, code and output.

econchick commented 9 years ago

Not sure one can link in between notebooks tbh. And if it's possible it still doesn't really easily solve the issue of tutorial source code having multiple modules. :-/

caynan commented 9 years ago

Just for clarification purpose...

@econchick when you say 'the language' you mean the text as we could see in the website right now, right? If so, I could assume that the actual source code is the sample code we find in the git repo, right?

@merwok by linking one notebook to another you mean like a hyperlink? if so it's possible and quite easy, take a look at this issue

@econchick what is the reason for putting all the tutorials in iPython Notebooks? With this information I think will make it easier for me to come up with some ideas.

We could take a look on what Allen Downey have done with his book Think Stats he uses iPyNBs almost as a interactive homework, where there is questions and the empty cells for answering also example code that the user can interact with in order to better understand the code.

econchick commented 9 years ago

@caynan - yea the 'language' I mean the website. The tutorials on the website has code snippets, which more often than not will not run without errors. That's why in the above IPyNB I created for sample-purposes, it has the code in a Markdown cell, not in actual Python/code cell.

The reason is for folks to lecture/host workshops based off of these. Currently, in newcoder.io/workshop, there are a couple of tutorials in PDF for folks to print off of and distribute, as well as the the tutorial in pure markdown so folks don't need to fuss with CSS if they were to print/distribute/teach off of. I just imagine a notebook would be a better way to distribute to teach off of.

Allen's book - I am just taking a look at one of his chapters right now. I see that he does in fact have empty cells. But the thing is - unless I haven't figured it out - a user/student can not actually input anything into those cells (maybe @allendowney can weigh in).

I was actually taking to Fernando Perez a couple of months ago about this exact issue - and IIRC it is not easy to setup something like that where the user/student has the ability to input code into a notebook (read/write capability) that is essentially sandboxed, not screwing up the actual notebook for everyone else (@fperez - please correct me if I'm wrong!). Sure, one can deploy a notebook instance on Rackspace (here), but it's typically either everyone can edit the one notebook, or read-only (which would act just like nbviewer.ipython.org).

caynan commented 9 years ago

@econchick, thank you for the quick response. Well it's good to know that the main purpose of the IPyNBs is to be used in workshops, so the idea is to make a notebook that could be used by a 'lecturer' to present the tutorials. Also making easier to distribute the content, since by using the IPyNBs you avoid having to create different formats for each tutorial, right?

Allen's book is intended for the user to read the chapter and in the end you have questions to practice the material on the given chapter, this exercises are given as IPyNBs, with empty cell for the user to fulfill.

The way it uses for the user being able to do this, is by requesting the user to pull the code from the git repo, and running the notebooks locally. I think this is the best way, in order to give the user a 'sandbox' for running, if anything goes wrong is a matter of dumping the changes.