Skip to content Skip to sidebar Skip to footer

Python: Am I Missing Something?

I'm in the process of learning Python while implementing build scripts and such. And for the moment everything is working fine in that the scripts do what they need to do. But I ke

Solution 1:

I would recommend that you read up on Generators, Iterators, itertools and above all List Comprehensions.

These are the pillars of anything Pythonic. And for everything else, there is PEP-8.

Read up on these concepts and try using them wherever appropriate. All the best!

PS: Don't forget to import this ;)

Addendum: I would also aggregate some excellent suggestions given by others in this thread here:

Solution 2:

No - this is common for folks who move to Python from other C-like languages. I believe what you are looking for is ways to make your code more "Pythonic". The good news is the more Python you write the more Pythonic your code will become. It is a natural overflow of the "how can I do this more simply" attitude.

Another good place to look at is The Zen of Python. These attitudes towards Python development will also help you in the same regard.

Solution 3:

You've gotten good suggestions so far. I'd only add Dive Into Python.

EDIT: As of Oct 4, 2011, this work can be found here. Dive Into Python 3, here. "Why" this is: see here, here and here.

Solution 4:

You should definitely take a look at this talk, when you start doing systems programming with python: http://www.dabeaz.com/generators/

Solution 5:

Recently I've been learning/improving my python by solving the Project Euler problems in python. This has worked really well for me because:

  1. It is fun and competitive, so I'm motivated to keep going
  2. It forces me to use the python data structures in a really natural way to get the performance I need, so has taught me a lot about lists, sets, strings, iteration etc.
  3. Most of the problems need less than a page of code to solve, so you have more time to think about polishing or rewriting in a more elegant way
  4. Python copes with large integers really easily, and so it just feels like the right language to use

I'd thoroughly recommend this.

Post a Comment for "Python: Am I Missing Something?"