Python best practices

Steven D'Aprano steve at pearwood.info
Fri Jan 15 21:32:45 EST 2016


On Sat, 16 Jan 2016 12:19 pm, gliesian66 at gmail.com wrote:

> Are there any good resources on python best practices?  e.g., articles


If you come from a Java background, you should read these two articles:

http://dirtsimple.org/2004/12/python-is-not-java.html
http://dirtsimple.org/2004/12/java-is-not-python-either.html

Everybody should read this:

https://realpython.com/blog/python/the-most-diabolical-python-antipattern/

Stop writing classes:

https://www.youtube.com/watch?v=o9pEzgHorH0

Start writing classes:

http://lucumr.pocoo.org/2013/2/13/moar-classes/

Contradiction? No, not really. You should understand when to write a class
when not to write a class. If you force everything to be in a class, you're
living in the Kingdom of Nouns:

http://steve-yegge.blogspot.com.au/2006/03/execution-in-kingdom-of-nouns.html

(discusses the Java model of "everything must be in a class")


Nearly everything by Raymond Hettinger, starting with these:

https://www.youtube.com/watch?v=OSGv2VnC0go
https://www.youtube.com/watch?v=wf-BqAjZb8M

Read the Python source code:

https://rhettinger.wordpress.com/2011/01/28/open-your-source-more/

(Older modules might not show "best practice" any more, but you can still
learn something from them.)

At the interactive interpreter, read the Zen of Python:

import this



-- 
Steven




More information about the Python-list mailing list