Mastering Python... Best Resources?

Travis Parks jehugaleahsa at
Fri Aug 26 14:58:46 CEST 2011

On Aug 26, 8:44 am, Chris Angelico <ros... at> wrote:
> On Fri, Aug 26, 2011 at 10:33 PM, Travis Parks <jehugalea... at> wrote:
> > I know the Python syntax pretty well. I know a lot of the libraries
> > and tools. When I see professional Python programmer's code, I am
> > often blown away with the code. I realized that even though I know the
> > language, I know nothing about using it effectively.
> I would say that there are three aspects to using Python effectively:
> 1) Understanding the syntax, which you've mastered.
> 2) Understanding the philosophy
> 3) Knowing algorithms.
> The second is more or less what you're asking for, but the
> language-independent third may be more useful to you. This is correct
> Python syntax (#1), and decently Pythonic style (#2), but a hopelessly
> flawed algorithm (#3):
> def fib(x):
>     return fib(x-1) + fib(x-2) if x>2 else 1
> Or:
> def fib(x):
>     if x<3: return 1
>     return fib(x-1) + fib(x-2)
> Both versions are clean and easy to read, but neither would be what
> I'd call brilliant code.
> You can get books on algorithms from all sorts of places, and with a
> very few exceptions, everything you learn with apply to Python and
> also to every other language you use.
> ChrisA

Well, I think I am going more for #2. I know about things like data
structures and algorithms... in your case memoization.

Here is a good example of what I am talking about. Someone took the
time to write quicksort in a single line of code:

def qsortr(list):
    return [] if list==[]  else qsortr([x for x in list[1:] if x <
list[0]]) + [list[0]] + qsortr([x for x in list[1:] if x >= list[0]])

I would never even think to use list comprehensions and splicing like
that. I would write this code the same way I'd write it in C++/C#. I'm
aware that writing code like the above example is probably bad
practice (and that the implementation here has some major
inefficiencies), but it is the "mentality" that goes into it.

I haven't gotten to the point where I can truly use the language
features to my full advantage. I haven't seen enough "tricks" to be
effective. I feel like there is so much of the language I am not
utilizing because I'm still thinking in terms of a less powerful
language. I was hoping to find a series that would familiarize me with
how real Python programmers get things done.

More information about the Python-list mailing list