Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

General question about Python

Kenneth is advising us to construct variable names in Python as (variable_name_all_in_lower_case). I am used to and really prefer (camelCaseWithNoUnderscores). How big a deal is it in the world at large? I don't want to buck the tide just for the sake of it. But I do prefer camelCase. In the course I think the challenges will require I follow the protocol, so I will.

Just asking.

Albert Reel
Albert Reel
5,555 Points

*removed to de-clutter.

1 Answer

Gianmarco Mazzoran
Gianmarco Mazzoran
22,076 Points

Hi,

what Kenneth refer is PEP8, which is one of the Python Enhancement Proposals.

Here's the link to the naming conventions

  • Basically when we use something_all_lower_case we are refer to a variable or a function.
  • When we use SomethingLikeThis we are refer to a Class object
  • When we use SOMETHING_LIKE_THIS we are refer to an immutable object.

This are just a few example, I suggest you to take a look at the page linked above. So if you follow this criteria you now your code it will be written like that of someone else. So hypothetically every file written in python is written the same way all over the world!

I hope I have given the right information and have helped you!

These conventions make sense now in light of PEP-0008.

Kenneth Love
Kenneth Love
Treehouse Guest Teacher

Great answer! Only thing I'd say is that SOMETHING_LIKE_THIS isn't necessarily immutable (we don't have much that's immutable in Python), but it's the convention for a constant which is expected to not change during execution. It's not enforced, though.

Gianmarco Mazzoran
Gianmarco Mazzoran
22,076 Points

Thanks Kenneth! :blush:

And thanks for better explanation!