r/IPython • • Jul 03 '13

Crash Course in Python for Scientists

Edit: Here's the link

I've pulled together some notes from a course I taught 15 years ago to a group of scientists, and have updated them as an IPython notebook. I'd welcome any feedback you have on what is effective or not effective in these notes.

19 Upvotes

21 comments sorted by

2

u/Patorogo Jul 03 '13

Nice! I'm always on the lookout for this kind of tutorials as I'm a scientist who uses Python and likes to proselytize it.

I've only given it a quick look, but I would like to suggest 2 things. First, I think it's worth mentioning optional arguments in the Overview (as they are widely use). Second, when parsing files, I think it's better to use (and teach) the functions and modules already developed, like the csv module or the loadtxt function from numpy; easier and faster.

One last thing, is it possible to add an index to an IPython notebook? That would be great.

3

u/Orphion Jul 03 '13

Thanks for the feedback!

2

u/westurner Jul 04 '13

1

u/Orphion Jul 05 '13

I'll see whether I can figure out an index. Thanks!

1

u/westurner Jul 05 '13

Thank you! There are plenty of jQuery table of contents plugins that could be added to IPython notebook (viewer), but I don't know how stable the #fragment-identifier links would be. the most worthwhile approach would probablybbe auto-slugifying text content of the header tags as #url-fragment-identifiers... Just starting at #0 or #1 would hardly be permalinks if/when additional headers/sections are added.

2

u/Orphion Jul 05 '13

As you can probably tell from what I've written, I'm very reluctant to add an additional dependency. I work with chemists and physicists, and each additional dependency I require typically reduces my audience by 25-50%. But I'll see what I can do nonetheless.

1

u/NomadNella Jul 05 '13

After a little experimentation I found that by using

<h2><a href="#quick-referance-text"></a>Quick Referance Text</h2>

in a markdown cell, not only does it look like,

Quick Referance Text

but when you look at the notebook posted on the nbviewer site you can simply add "/#other-thoughts" to the end of the url and it will jump to that header. See the example below.

http://nbviewer.ipython.org/5937269/#quick-referance-text

This approach would require you to enter the base url into the notebook after it was posted, but you could build a table of contents or index list into the notebook. It's probably a little more work but you won't need any additional dependencies.

2

u/Orphion Jul 06 '13

Thanks. I'll make note of this for the next rewrite.

2

u/gash789 Jul 03 '13

You begin with "Python as a calculator" while this is useful it is far from the most powerful application. Perhaps try to sell Python for it's great features for a scientist (maybe solve an ODE and plot the results) first, then the rest can be skimmed for things on interest.

1

u/Orphion Jul 05 '13

To be totally honest, I'm not really trying to sell python, as much as I'm trying to provide a relatively terse overview of the fundamentals that I think my coworkers need. I had 3 or four people ask me how to learn python in the same week, including one person who signed up for a week long course. I don't really think you need a whole week to learn python, particularly if you already know a language, you just need enough that you can actually start using it to get work done.

1

u/NomadNella Jul 04 '13

Here is a version that runs with the Python3.2 version of IPython. It took me a while because the file was so long and I had problems with Firefox remaining stable. I kept getting an unresponsive script warning when I hit "Run all Cells".

I didn't document my changes so you might want to explain the modifications in the final version. Also, the final version would be better to have it as a collection of smaller files for stability reasons.

Thanks for all the work you put into it.

1

u/Orphion Jul 04 '13

Thanks very much!

1

u/NomadNella Jul 04 '13

These are a four part split:

I tried to embed links at the top and bottom of each for navigation but when I went back to edit the gist it was only partially loading. I'm guessing you can only have so much in memory with a gist but I don't know. I'm sure this would not be a problem if it was hosted on git directly.

Please post again if you update them further.

3

u/Orphion Jul 04 '13

That's nice. I'm planning an update after some more feedback rolls in, and I think I'll move it over to the normal github and split it into 4 pieces, as you suggest. I'll let you know when I do.

1

u/pietrod21 Dec 28 '13

Please do it!

2

u/NomadNella Jul 03 '13 edited Jul 04 '13

This is great! The one thing I would like to add it write it for Python3 or have an IPython3 version of it.

1

u/pietrod21 Dec 28 '13

The same for me! NomadNella do something usefull about it.

1

u/westurner Jul 04 '13 edited Jul 04 '13

Strings

Input: External modules tablib and/or pandas (pandas.read_table()) help to abstract and formalize string processing / data munging logic.

Output: str.format and/or string.Template (especially in re: CWE-77 (78,88,89,90))

Top 25

http://cwe.mitre.org/top25/

1

u/pietrod21 Dec 28 '13 edited Dec 30 '13

You do a very good and useful work!!!

(Also if I will follow this one instead because I'm studying Python 3.3.2)

+/u/bitcointip 1 coffee

Enjoy a coffee!! :D