Discussion:
[Tutor] variable naming conventions
D Wyatt
2015-08-16 01:24:53 UTC
Permalink
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.

Thanks in advance,
--
Deb Wyatt in WA
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Joel Goldstick
2015-08-16 01:29:32 UTC
Permalink
Post by D Wyatt
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.
Thanks in advance,
--
Deb Wyatt in WA
_______________________________________________
https://mail.python.org/mailman/listinfo/tutor
lower case. underscores
--
Joel Goldstick
http://joelgoldstick.com
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Mark Lawrence
2015-08-16 01:40:37 UTC
Permalink
Post by D Wyatt
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.
Thanks in advance,
If it's your code for your use do whatever you like. I prefer camel
case as it saves reaching for the SHIFT-MINUS combination, others detest
it. Even the famous PEP 8 (https://www.python.org/dev/peps/pep-0008/)
is only a guide.

However if I was working on a project in collaboration with others I
would certainly expect to stick with the standards that the project
insisted on, even if I didn't like them personally. Anybody who
deliberately ignores standards in this situation should be hung, drawn
and quartered after spending an extremely long amount of time in agony
in The Comfy Chair :)
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Cameron Simpson
2015-08-16 02:25:50 UTC
Permalink
Post by D Wyatt
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.
Ideally, anyway.

If you're not invested in another style, and not working in someone else's
codebase with its own conventions, try PEP 8.

Cheers,
Cameron Simpson <***@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
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Laura Creighton
2015-08-16 07:00:37 UTC
Permalink
Post by D Wyatt
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.
Thanks in advance,
--
Deb Wyatt in WA
The Python Community is too large now to have only one preference.
People's preferences for CamelCase or this_uses_underscores is usually
language independent -- if you prefer it when you are using language
X, you probably prefer it when you are using langauge Y, too.

The Python Standard Library, for the most part, uses underscores
for variable names and CamelCase for class names. See PEP 008 for
'preferred Python Style' -- such as it is, but be aware that if you
join a project it is more important to follow the conventions used
there than to hop up and down saying ....'This is not PEP 008 !'

Laura
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Ben Finney
2015-08-16 08:14:27 UTC
Permalink
Post by Laura Creighton
The Python Standard Library, for the most part, uses underscores
for variable names and CamelCase for class names.
Note a sharp distinction between camelCaseNames, which the Python
community eschews, versus TitleCaseNames, which are embraced for names
of classes.
Post by Laura Creighton
See PEP 008 for 'preferred Python Style' -- such as it is, but be
aware that if you join a project it is more important to follow the
conventions used there than to hop up and down saying ....'This is not
PEP 008 !'
Yes. If you're looking for a style guide, choose PEP 8, because your
style will then be maximally familiar to others when you inevitably need
to collaborate with some other people.

If you're joining a community that doesn't have consistently-enforced,
coherent conventinos, make a strong push for PEP 8 for the same reason.

But if you're joining an existing community that has chosen a coherent
convention which it enforces consistently, go with that.
--
\ “We demand rigidly defined areas of doubt and uncertainty!” |
`\ —Vroomfondel, _The Hitch-Hiker's Guide To The Galaxy_, Douglas |
_o__) Adams |
Ben Finney

_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
http
Continue reading on narkive:
Loading...