views:

295

answers:

5

Is there any online resource or a book that provides common code snippets? I really like the "Python Phrasebook", but it doesn't cover Python 3.1.

I'd appreciate your comments and advices. Thanks!

+6  A: 

The Python Cookbook (also available in book form -- more date but with lots of selection, editing, expanded discussion, etc -- I'm biased towards the latter of course) may be similar to what you ask, except it doesn't just provide "snippets", but also explanations of the problems being tackled, discussion of alternatives, explanations of why one approach may be preferable to another, and so on.

Alex Martelli
That's a great resource for Python.
Andrew McGregor
Yes, I wanted to get it but its quite old (2005), can you please please include v3 in the next release! :)
Nimbuz
@Nimbuz, somebody else will have to take the point position in editing the printed CB's 3rd edition -- I'm just too busy (it takes enormous amounts of time -- more than writing the Nutshell, believe it or not!) and so is my wife-and-coauthor Anna. But the online CB does have some Python 3 recipes, no?
Alex Martelli
A great majority of the cookbook is still relevant.
darren
+2  A: 

Read this tutorial for Python 3.1.

Prasoon Saurav
A: 

If you are starting out in Python development, it may be a good idea to start with Python 2.5 or 2.x (x being the latest version). This is because Python 3.x is not backwards compatible with 2.x version and you are better of learning the fundamentals from 2.x and then learning whats different in 3.x.

omermuhammed
Almost all the changes in v3 make a lot of sense, and because there aren't too many 'major' changes, I prefer it over v2.
Nimbuz
The changes in Python 3 are great. However, it's important to note that the vast majority of libraries are not yet available in Python 3. Thus, Python 3 is a wonderful choice as long as your project isn't big enough to require any popular libraries. (Then Python 3 is a wonderful choice only if the libraries you need are ready for.) In a couple more years, Python 3 will likely be a sensible starting point for most projects.
Travis Bradshaw
A: 

Found this Python code snippet collection (23 pages). Some of those aren't compatible with v3.x but still a pretty helpful.

Nimbuz
+3  A: 

You might like Dive Into Python 3. It's an online book that has lots of useful snippets.

jbochi