Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,052 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,052 Points

Thanks Kenneth! :blush:

And thanks for better explanation!