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 Python Basics (2015) Python for Beginners Syntax and Style

Kostas Triaridis
Kostas Triaridis
268 Points

Name of a function or variable

In the video Kenneth mentions that function and variable names should use a syntax/style like this: a_new_function Does that mean that a name like aNewFunction is incorrect?(I use that style of writing in my c++ code) because he doesn't mention something about capital letters. Thanks!

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! The style that you're used to using is known as "camel case". This is used as the standard style of writing variable and function names in several languages such as C++/C#/JavaScript/Swift and others. Python is a little special and uses what is known as "snake case". It's not so much that "myFunction" would be incorrect, but rather "my_function" would be considered more standard in Python. It's just the style that Python has chosen to be the default.

That being said, there are other languages that also use snake_case including, C, Ruby, and PHP (in some cases).

Hope this helps! :sparkles:

Kostas Triaridis
Kostas Triaridis
268 Points

Thank you very much for your quick answer :D