Code Conventions - IncrediCoders/Python1 GitHub Wiki

paul_ch1_avatar

Paul Python added this page on July 29, 2025


What are code conventions? We're glad you asked!

Code conventions are the code styling decisions we made in the book. Each convention and decision was made for various reasons, so let's get into it!

Table of Contents:

Case Styles

Typically, there are a few core casing styles (also called casing conventions or simply casing) that developers use: Snake Case VS Camel Case VS Pascal Case VS Kebab Case – What's the Difference Between Casings?

Dionysia Lemonaki did an amazing job writing that article that explains the different casing styles.

You name a lot of variables and functions when you code, so you want to be consistent with your naming conventions.

One thing to keep in mind is that the names of your variables and functions can't have spaces in them. So, these casing conventions don't include spaces, and they exist to make sure that the names you choose are consistent in how they appear.

Here is a very brief summary of the different casing styles:

  • camelCasing: Although the first word starts with a lowercase letter, each new word starts with a capital letter. It uses no spacing or dashes in between the words. This is also called medial casing (since you use uppercase in the middle), and it was started for the chemistry industry in 1813.
  • PascalCasing: A form of camel casing, this is also referred to as CamelCasing, where the first word has a capital "C." It was named after the Pascal programming language, which uses Pascal casing.
  • snake_casing: It uses an underscore between each word. It's also called underscore casing.
  • kebab-casing: It uses a dash between each word.
  • ALLCAPSCASING: Also known as the screaming case, it's all caps.
  • SCREAMING_SNAKE: All caps with snake casing, where you have an underscore between each word.

We landed on using three of these casings for the book:

  • Snake Casing: We use snake (or underscore) casing for functions, such as this_is_a_function(). A function is basically where you call a bunch of code to do a thing. More on that later.
  • Pascal/Camel Casing: We use the Pascal style of camel casing (with the first letter capped) for variables and lists.
  • All-Caps Casing: We use all-caps casing (also called scream casing) for environment variables, global variables, and ENUMS which are basically just variables that don't change (we want to keep the value throughout the program) or that are used across multiple functions, modules, and even files. For example, the variable SCREEN is in all caps, because it is an environment variable, which means that it sets up the environment. The environment includes things like the background, window, or screen.

Line Length

In the book, you will find some short lines of code and also some longer ones. A few of the long lines are shown across two printed lines so they can fit on the page. We do this on purpose to give you practice with both simple and more complex code, and to help you get comfortable reading, using, and fixing longer lines of code when you need to.

Initialization Files

An initialization file runs automatically when your program starts. It sets up important settings, prepares data, and ensures everything is ready before the main code runs. Think of it as your program’s “morning routine." Like "packing your bag" before going to school.

More resources about initialization files: Level 2: Initialization Files

Displaying Text

Because we’re displaying text in game windows, we draw the text to the screen. We don’t use the print() function, which prints to a text console.

Code Files

Throughout the book, we have a template file for readers to fill in the missing code. We also have the full solution files, which contain all the completed code.

The Repo Structure article provides a detailed walkthrough of all our files on this GitHub repo: Repo Structure

Advanced Coding

These advanced techniques include docstrings (which we use a little in this book; these are like comments), sets (instead of lists), exception handling (which is especially useful for programs with data entry), advanced debugging (and the logging module), f-strings for organized string formatting, and list comprehensions (which we use a little).

Next Steps

We hope you took all that to heart, and you're ready to learn (or to continue learning)! Let's get back to the book! And you should probably also check out the rest of our resources, at IncrediCoders: Python Adventures - All Online Resources.

And you can take a gander at all the rest of our Big Book Buddies, which are pages we have on the Wiki that help out as buddies of the book!

⚠️ **GitHub.com Fallback** ⚠️