Python: Am I Missing Something?
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:
- Read Code Like a Pythonista: Idiomatic Python (from David Grant)
- Solving problems from Project Euler is a great idea (from Nick Fortescue)
- This excellent presentation on Generators and Iterators by David Beazley (from André)
- Learn about Scons (from the venerable S.Lott)
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:
- It is fun and competitive, so I'm motivated to keep going
- 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.
- 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
- 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?"