Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Names: Recap

Here’s a recap of what you’ve learned about naming conventions:

  • Variable names can be of any length.
  • As of Python 3, you can use Unicode characters.
  • You can use integers, but not at the beginning of a variable name.
  • For regular variables, use lowercase and snake case.
  • For constants, use uppercase.
  • For classes, use CapWords.

00:00 Here’s our quick recap on variable naming in Python. We looked at naming conventions. What are different naming conventions? There’s, like, no limitation on the length of the variable name. It can be super long, it can be very short, just the one character. We said that starting from Python 3 we can also use Unicode characters, so something like voilà is possible for now, which is good for a couple of additional languages that use different characters than the English language. Then we said that we can use integers, but we cannot use them at the beginning of a variable name.

00:33 So something that is just an integer or starts with an integer would be wrong and produce an error, but you can include the integers somewhere at the end or somewhere in the middle, using underscore or not—that’s all fine.

00:47 We learned that the suggestion is, while this is not going to produce an error here, using a mixed case like that—really messy—you don’t want to do that, because it’s just not easy to read.

00:57 It makes your code more difficult to understand. So there’s these couple of conventions that you want to stick to, which means that for normal function, variable names, you just use lowercase and snake case.

01:08 We’ll talk about this more. And for constants, uppercase characters. And for classes, you use CapWords, so it starts off with a capital letter and every new word starts off again with a capital letter.

01:22 So, snake case. For 80% of your Python needs, that’s what you’re going to do—especially when you’re a beginner. You just default to using snake case. A good variable name should look like this.

01:32 You start off with a character and each word is separated by an underscore (_). It makes it easy to read, good to look at. And, you know, the snake. Snake case. The snake is watching you! Okay, you get it. Next, we looked at PEP 8, which is the Python Enhancement Proposal that deals with these coding naming conventions in Python. It’s a style guide.

01:56 You’ll hear it mentioned around a lot, and now you know where to go to take a look and you know it’s just a document that you can read over. Don’t be scared of it, it’s got a lot of helpful information in there, and use it as your resource to go back and check up on how you should style your code.

02:13 And that’s all for this section. We’re moving into the final section, where we’ll talk a bit about reserved keywords in Python—things that you cannot assign as variable names. See you there in the next video!

Avatar image for Damian

Damian on Feb. 22, 2020

haha.. got it! snake_case is the way to go.

Avatar image for Martin Breuss

Martin Breuss RP Team on Feb. 23, 2020

snake_case_all_the_way_🐍😉!

Avatar image for Harsh Chaklasiya

Harsh Chaklasiya on May 3, 2020

hahaha_snake_is_watching_you

Become a Member to join the conversation.