Writing Idiomatic Python Book
jeffknupp.com
jeffknupp.com
Can't afford the book?
Not a problem
If your financial situation doesn't afford you the
opportunity to purchase the book, email me at
jeff@jeffknupp.com and I'll happily send you a free
copy. Just be sure to note in your email which version
you'd like.
See, now that's just classy. I was on the fence about whether or not to buy before seeing that and somehow it tipped the balance for me. No idea what it's doing on the whole for your conversion rate, but it definitely helped here!I wish this kind of thing would go into the core python documentation though. So new Python programmers learn to 'think' python.
--- [1] http://www.jeffknupp.com/blog/2012/10/04/writing-idiomatic-p...
print(index, element)
instead of print ('{} {}'.format(index, element)) ?
Why use string formatting for something so simple, especially when Python inserts spaces in between multiple items automatically?Also the "don't write this" looked awfully familiar.
1. The idioms are generally the most elegant way of using the language, so if you use them, it means that you will use the language in the most efficient manner ("with" statement for file handling is one example);
2. It's easier for other people to work with your code;
3. You feel good knowing you're doing the right thing.
4. Idiomatic code receives more attention from the Python core developers and might become faster in the future (for free!).