Python best practices

Bob Gailer bgailer at gmail.com
Sat Jan 16 14:41:33 EST 2016


On Jan 15, 2016 8:20 PM, <gliesian66 at gmail.com> wrote:
>
> Are there any good resources on python best practices?  e.g., articles

What programming experience do you have? I'm thinking of languages.

Here are a few of my guidelines - most not Python specific:

Keep logic and data separate.

Comment early and often - but don't comment the obvious.

Use meaningful names.

Read the manuals.

Get familiar with modules. Someone has likely already solved the problem.

Do not override built-in names.

Follow these email lists.

Avoid things like "if valid == True:".
"if valid:" is sufficient.

Read the manuals.

When asking for help:
  Use a problem-specific subject.
  Use plain text so code keeps indentation
  Mention your Python version and OS.
  Include any traceback.

If something is not clear try it in the interactive window.

Dictionaries are very useful. Get familiar with them.

HTH.



More information about the Python-list mailing list