Hacker News new | past | comments | ask | show | jobs | submit login
Python Practice Book (anandology.com)
204 points by aburan28 on Aug 8, 2014 | hide | past | web | favorite | 36 comments

FYI: It's Python 2, teaching Python 2 syntax.

Given the state of the whole 2 vs. 3 debate, I'm always surprised that libaries and books don't post their requirements or used versions more prominently.

Most of the writing are Python 2 and 3 compatible (sure the print statement is enough to throw Python 3 off) and this was written back in 2012 when Python 2 was still the center of the community. Maybe the author thinks writing down the interpreter (Python 2.7.1) on the first chapter is good enough. Also, this was prepared for a training if you read the side. So students who took the author's training probably knew it was for Python 2.

Although I do spot a couple really "non-standard" practice, for example, the classes still using the old Python 2 syntax:

class Name: vs class Name(object):

Actually, leaving out `object` is the preferred convention for Python 3, as they are semantically equivalent. In Python 2, they mean different things, and you generally want to mean `class Name(object):`. Explicit is better than implicit.

Why is this a 'preferred convention' for Python3? Doing this causes a lot of confusion for Python beginners that write code in Python2 (i.e. it causes them to accidentally use old-style classes). A better practice is to add the extra word i.e. 'class ClassName(object):' for both Python2 and Python3 code. This is especially true if you are writing Python tutorials. Since we are going through this Python2 to Python3 transition it is better to minimize the differences in the cases where they don't really matter (i.e. add the extra 'object' word).

It's considered a wart that old style classes even exist in the first place. Classes look way nicer without it.

Imagine having to write `extends Object` for every Java class you make.

If you have Python 2.7.5, then print('hello') just works for you.

Thanks for the suggestion. Added a note on the index page.

Ever since completing the Codeacademy Python course, I've been looking for simple but practical python projects that can help me learn to apply my skills. But so far the projects I found have been either too difficult or too simple (textbook like). I wonder if there is a more structured project-based learning material out there? Any suggestions?

This sounds exactly like what you're looking for! [0]

You’re a new coder. You’re interested in learning how to code, not just syntax. You’re sick of monkey-see, monkey-do types of tutorials.

Let’s set your teeth into some real coding. Your hand will be held in the beginning, but as you progress you’ll see yourself approaching the projects more comfortably.

[0] - http://newcoder.io/

This looks cool! Will give it a go over the weekend. Thanks for sharing!

Know the feeling. Same for me (beginner, completed Codeacademy...). The easy exercises here http://www.reddit.com/r/dailyprogrammer are within our reach and there's always at least one solution implemented with python.

Thanks for sharing! And good to know there're fellow programming learners out there sharing my pain/passion. This looks like what I was looking for. Will give it a go over the weekend!


This is a collection of real applications that are written in 500 lines or less. The goal is to teach python through real projects that are not too complicated to understand.

Hope this helps.

It's not specifically for python, but I have found the exercises at http://programmingpraxis.com to be really good for this kind of thing (and the comments will usually contain some solutions in python).

This still seems more mathematical/text-book like than practical examples, reminds me of https://projecteuler.net/ which is fun to do. Thanks for sharing!

This in general is my issue with books about (learning) any subject; there are a lot of beginners books and web sites and there are a lot also of specialized books that go into details but there are few or no good intermediate books (to start the mastery after the basics). I find that the famous books that people always bring up are precisely in this category.

I would recommend Learn Code the hard way series http://learnpythonthehardway.org/book/ http://learncodethehardway.org/ Its pretty good!

For Ruby, I enjoyed http://rubykoans.com . There is a python port (which I haven't tried) at https://github.com/gregmalcolm/python_koans .

You should really pick something you care about and solve a problem in that area. You will be more motivated, you will learn faster and you choose the complexity!

Problem is what I want to build is far more complex than what I can build right now, need to take baby steps ;)

My suggestion would be to try doing it anyway and see how far you get. Even if it's some type of machine learning / AI thing, you might be able to do something like throw your data Alchemy ( demo: http://www.alchemyapi.com/products/demo/alchemylanguage/ ) and have it do the "hard part".

You'll learn a lot along the way and you'll then know exactly what you need to focus on more if it totally doesn't work, but you'll likely find enough success in whatever it is that you'll be very motivated to build v2 learning from all your mistakes along the way :)

What sort of projects do you have in mind? I say try to tackle one of them and look for answers to your questions along the way.

Just build something for yourself. Something complicated but not too complicated. Best way to learn in my opinion.

Highly recommend https://projecteuler.net/

Yes I've done a number of these challenges, agree it's really good and would recommend to others. However this is still quite mathematical/text-book like (in a challenging and fun way though).

Hmm, noticed a few mistakes in the Getting Started section, both code, grammar and spelling. Where can we submit issues?

...and I'm surprised there's a whole section on using recursion in Python, considering Python guards against recursion depth. (tail recursion is especially applicable here). The author seems to have a solid understanding of Python, so I'm a little confused.

In general, if you use recursion in python, you're gonna have a bad time. Better to use an iterator (which is usually more memory efficient anyway because you're not slurping up the whole thing...).

Of course, you can always hack it and sys.setrecursionlimit, but WHY WOULD YOU DO THIS. https://docs.python.org/2/library/sys.html#sys.setrecursionl...

Please submit an issue on github.


Just looking through the Contents it seems like a more elaborate Tutorial? At least for me the title suggested that this book is for people who are already intermediate/advanced Pythonistas who want to improve their skills. Would be great to find a book like that.

Looks like this has been fixed now; latest takes you to the Python 3 page. ...and py3 takes you to the python 2 page O_o

py3 branch is the Python 3 version, which is a ongoing work.

made by "sphinx"....another python masterpiece !!

This is awesome. I wish this was extended to teach more advanced topics such as how to create reusable packages, big O notation, etc.

Great piece of work and truly interactive learning. Its gonna fun to learn python.

Registration is open for Startup School 2019. Classes start July 22nd.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact