User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Best book to learn python?

Sat Mar 03, 2012 8:42 pm

Since python is the language preferred/intended by the RasPi foundation, I thought I'd learn it. I've been going through the tutorial on the python site which is good, but in the past I have learnt programming languages from books. I like to get away from the screen as I stare at screens far too long already.

I've got some programming experience - starting with commodore pet 8k on BASIC, through BBC and Spectrum BASIC, onto REXX then QBASIC, then PERL and a bit of Javascript, with a large helping of HTML4. My most advanced stuff has been in PERL. (Banner serving and shopping cart - and several other web back-end scripts).

Any suggestions? A popular recommendation is Dive into Python. Any others? I might just do something very old-fashioned and visit a high-street bookshop to look through the titles. (Haven't bought a book in a shop for years LOL).

I am interested in tutorials too, but I want a book. Also, are there any applications in the pipeline to support learning python on the Pi?
Alex Eames RasPi.TV, RasP.iO

samarthwiz
Posts: 4
Joined: Sat Mar 03, 2012 9:13 pm

Re: Best book to learn python?

Sat Mar 03, 2012 9:21 pm

This is the best book for kids Helloworld!

Books website: helloworldbook.com

andyl
Posts: 265
Joined: Tue Jan 10, 2012 11:05 am

Re: Best book to learn python?

Sat Mar 03, 2012 10:36 pm

I think that Dive Into Python will be OK.  Pilgrim is a fairly idiosyncratic writer - DiP contains plenty on Unicode, some of which the publisher has cocked up in the print version from what I read.

Maybe Learning Python would suit.  It isn't a complete newbie guide to programming with Python but aimed at a novice programmer like Dive Into Python.

If you characterise your programming experience as quite strong then Programming in Python 3: A Complete Introduction to the Python Language (2nd Edition) might be better

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Best book to learn python?

Sat Mar 03, 2012 10:54 pm

Thanks both. I'm interested in both angles actually. I want to get advanced myself but I also want to teach it to kids.
Alex Eames RasPi.TV, RasP.iO

xalixo
Posts: 16
Joined: Fri Feb 03, 2012 11:03 pm

Re: Best book to learn python?

Sun Mar 04, 2012 10:42 am

At the moment I'm using "python programming for the absolute beginer". Its highly recommended on amazon. I've got the third edition, which covers python 3. I'm about a third of the way through and so far it's pretty easy going. By the looks of it, as you build up your skills you start to make games using pygames.

Compared to other programming books I've tried in the past (C++) the progression is at a nice easy level for beginners, but this could be due to python also being an easier language.

I can't fully recommend it yet because I haven't finished it, but you might want to consider it to help with teaching. Every exercise is made to be fun, so it's definitely not a dry, boring textbook.

spurious
Posts: 343
Joined: Mon Nov 21, 2011 9:29 pm

Re: Best book to learn python?

Sun Mar 04, 2012 10:47 am

Just Google'd and found this:

http://docs.python.org/tutorial/

anndra
Posts: 5
Joined: Mon Aug 29, 2011 3:42 pm

Re: Best book to learn python?

Sun Mar 04, 2012 1:03 pm

I used 'How to Think Like a Computer Scientist: In Python,'  I had to learn python very quickly while at Uni last year and this was the best free resource I could find.

http://openbookproject.net/thi.....english3e/

It was adapted from the Java version by a high school Computing teacher.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Best book to learn python?

Sun Mar 04, 2012 2:18 pm

spurious said:


Just Google'd and found this:

http://docs.python.org/tutorial/



I'm working through that one already. I'm on chapter 5 and liking it so far.
Alex Eames RasPi.TV, RasP.iO

bobba_dwj
Posts: 14
Joined: Sat Jan 21, 2012 6:06 pm

Re: Best book to learn python?

Sun Mar 04, 2012 9:36 pm

I found this one very good when learning myself, it comes in Python 2 or 3 varieties:

http://www.swaroopch.com/notes/Python

Moreover, the author of "Invent With Python" has just released a book on Python and Pygame:

http://inventwithpython.com/chapters/

http://inventwithpython.com/py...../chapters/

Finally, Cambridge University has a course with downloadable slides and are very clear and easy to read:

http://www.ucs.cam.ac.uk/docs/.....s/PythonAB

We really are spoiled these days with fantastic on-line resources, all free of change.

bobba_dwj
Posts: 14
Joined: Sat Jan 21, 2012 6:06 pm

Re: Best book to learn python?

Mon Mar 05, 2012 10:05 am

One more thought, if you would like a actual book to read, I would recommend "The Quick Python Book" by Vernon Ceder, 2nd edition.  I got mine from the book depository, and found it extremely readable.  If you buy it, you can also download an electronic version from the publisher's web site with the codes provided, which is handing for searching the text later on.

joohoo340
Posts: 1
Joined: Mon Mar 05, 2012 3:21 pm

Re: Best book to learn python?

Mon Mar 05, 2012 3:29 pm

I have found that for teens and high school students in the states respond nicely to this book I found online

http://learnpythonthehardway.org/

Its a bit more engaging and not so lofty in terms of pure theory and gives them a faster start to get down and dirty with python.

Best of all the html version is free or if you want to get the latex source for it and compile your own pdf version for offline use.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Best book to learn python?

Tue Mar 06, 2012 3:25 pm

Thanks all so far. Some good resources listed.

Lots of stuff online, but most print books seem to be a bit dated, which I suppose they are by definition really.

I've ordered the helloworld book from Amazon, which should be good for the teaching side of things, but I'm still pondering a more reference type book for me. Perhaps I'll hold off on that for now and work through some of the online stuff (I notice a couple of the open book project links above offer .mobi versions pretty cheap, which might work well for me on a kindle, which is nearly a book )
Alex Eames RasPi.TV, RasP.iO

wob86
Posts: 8
Joined: Wed Mar 07, 2012 10:41 am
Contact: Website

Re: Best book to learn python?

Wed Mar 07, 2012 10:48 am

I write in Python  a lot and always have a copy of core Python nearby.

amazon link

It is huge and a great refrence on the simple things (for when its a bad day and your brain just isnt kicking in!) but also has loads of info on the mre advanced parts as well.

dextrus
Posts: 119
Joined: Tue Jan 24, 2012 10:10 pm
Location: Eastleigh, Hampshire
Contact: Website

Re: Best book to learn python?

Wed Mar 07, 2012 8:15 pm

Rather than relying on a book, wouldn't it be more prudent to choose a project (say, "space invaders" or "staff holiday system") and glean what you can from the various sources available to you (and I would say this source is a key starting point)? Otherwise you risk tying yourself to the author's opinions, and that has been devastating for some of my students. A lot of these books or online tutorials are not written well and the code offered is biased to what the author wants you to do. A book is not your solution, IMHO.
Have more FUN with your Pi. Visit www.pi-fun.com

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Best book to learn python?

Wed Mar 07, 2012 9:40 pm

dextrus said:


Rather than relying on a book, wouldn't it be more prudent to choose a project (say, "space invaders" or "staff holiday system") and glean what you can from the various sources available to you (and I would say this source is a key starting point)? Otherwise you risk tying yourself to the author's opinions, and that has been devastating for some of my students. A lot of these books or online tutorials are not written well and the code offered is biased to what the author wants you to do. A book is not your solution, IMHO.


You're right, that's another way and I'm planning on doing that too. My first project is to build a program as an aid to scrabble. (Although I love Space Invaders too – it would be positively rude not to do that next.) Not just an anagram word finder, but words beginning with *, words with * as third letter etc. I know there's a hundred and one of those programs already, but that's not the point. It's for fun. Still, though, you have to know a certain amount before you can begin that sort of thing.

I like books. I learnt PERL by reading books. I like to get a complete overview of a language (and a heck of a lot more than you might expect lodges in the brain) before and during a project. Once you have this overview, when you think "how do I do this?" it's amazing how often you remember that obscure function you happened across somewhere in chapter 17. Maybe it's just me, but I did this with REXX and HTML as well?

At the moment I am doing online tutorials and reading a couple of the free links in this thread. Also managed to get a PDF onto my kindle of one of the titles (invent with python, I think). It's going OK so far, but I haven't given it a lot of time yet.

The only thing that now puts me off paper books is that they age so quickly. There was a recommendation above for core python that I nearly pulled the trigger on, until I saw how old the book was. Second edition 2006 – that's an awful long time in this field. (And then you get the dreaded Python 2 or Python 3 debate LOL)

Thanks everybody for the suggestions. I have taken something useful from every post. I hope this thread will help others along their ideal path to learning Python.
Alex Eames RasPi.TV, RasP.iO

bobba_dwj
Posts: 14
Joined: Sat Jan 21, 2012 6:06 pm

Re: Best book to learn python?

Thu Mar 08, 2012 10:13 am

I think there is a balance, writing code (so that the knowledge sinks in, and you challenge/correct your own assumptions), but also reading books so that the gaps in your knowledge aren't too great.  It is so easy to hack code out, without realising that you are doing it the hard way.

I read "The Quick Python Book", and it's very readable and quite up-to-date.  Python is evolving, yes, but not that quickly, and as mentioned elsewhere, the differences between Python 2 and 3 are not that great (and this book covers both).  It doesn't cover the entire language, and often refers you to the language reference, but it is a good overview.

If you are after a better reference book, "Python Essence Reference" by David Beazley is highly thought of, and I got a copy at the same time as the Quick Python Book.  It is not intended as an easy read, but it is a good book to have around as it goes into much more advanced subjects such as multi-threading and networking.

To top it off, I got my son the "Python Programming for the Absolute Beginner" by Michael Dawson which he enjoyed, I think he read it in about 2 or 3 days!

error404
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm

Re: Best book to learn python?

Thu Mar 08, 2012 7:00 pm

I see you found something, but I'll +1 Learn Python the Hard Way, though it might not be ideal if you've got prior programming experience. It is available in physical book form as well if that's what you're after. http://www.lulu.com/product/pa.....n/18839751

Dive Into Python used to be one I'd recommend to people with prior experience in other languages, but it has become somewhat dated and unmaintained. There's a new version out there somewhere with some updates, but it's still not really current IMO.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Best book to learn python?

Thu Mar 08, 2012 7:07 pm

joohoo340 said:


I have found that for teens and high school students in the states respond nicely to this book I found online

http://learnpythonthehardway.org/


I got to chapter 6 of the python tutorial and then my eyes glazed over. So I switched to joohoo340"s recommendation for a bit. I will certainly go back to the Python site one at some point though.

I"ve been working through this one and am currently on exercise 21. In the meantime I"ve accumulated enough knowhow to write one of the functions in my "scrabble assistant" program. In the end the Python was fairly straightforward, but I wrestled for quite a while to get the RegExp pattern and syntax right for the function I wanted (I wanted to use a variable, so couldn"t use a raw expression, then it took ages ro realise I had to escape the w using an extra backslash). Got there in the end though. Still a long way and a lot of loopy anagram/wildcard functions to go.

Should have the Manning book arriving tomorrow. Have decided to learn Python 2 for now. I"m running 2.7.2.

Edit to add a couple of days later...

My lad is sitting at his computer assigning variables in IDLE. He's delightedly just erased one of his teachers from the computer's memory (reassigned a variable).

This Hello World! Warren Sande book seems to be perfect for where he is at right now. (A fairly bright 9). I hope it will continue like this. If it does, it'll be a big hit.

As for me, I'm up to lesson 23 on the http://learnpythonthehardway.org/ book but I'm spending more and more time working on my own scripts and researching the functionality I need. That's real learning the hard way, but the hard lessons learnt are not quickly forgotten. I've got my scrabble search program working on 5 modes now...

starts with, contains, ends with, exact match and anagram (variable length).

With a dictionary of 178k words, anagram is fairly cpu intensive, but I've found ways to reduce that.

Most importantly of all though - we're both having fun learning Python
Alex Eames RasPi.TV, RasP.iO

Return to “Python”