[Tutor] variable naming conventions
cs at zip.com.au
Sun Aug 16 04:25:50 CEST 2015
On 15Aug2015 18:24, D Wyatt <fiberfolly at gmail.com> wrote:
>It seems every book I read these days uses camel case for variable names in
>Python. I was once told that using underscores is preferred. Is there a
>preference in the Python community or does it really matter? I'd like to
>instill good habits while I'm learning.
PEP 8 is lowercase with underscores for normal variables. Class names tend to
be CamelCase. I try to follow this. One advantage in staying with this is that
you share this convention with the stdlib and with a lot of other Python code,
which make it easier for you to read because it aligns with your own habits.
If you're not invested in another style, and not working in someone else's
codebase with its own conventions, try PEP 8.
Cameron Simpson <cs at zip.com.au>
Oh, what tangled webs we weave,
when first we practice to deceive.
And when we've practiced for awhile,
How we do improve our style! - Dorothy Parker
More information about the Tutor