Stealing pages from the server...

Why We Need PEP


Introduction

PEP8 was designed to make Python code more readable. If you’re new to Python, remembering what a piece of code does a few days or weeks after you created it can be challenging. If you follow PEP8, you may be able to assure that your variables have been properly named.

Naming Conventions Styles

Type Naming Convention Examples
Function Lowercase and underscores function(), my_function()
Variable Lowercase and underscores x, var, my_variable
Class Start with uppercase and without underscores Model, MyClass
Method Lowercase and underscores class_method(), method()
Constant Uppercase only and separate with underscores CONSTANT, MY_CONSTANT
Module Lowercase and underscores module.py, my_module.py
Package Lowercase only package, mypackage

Conclusions

Choosing names for variables, functions, classes, and other objects can be difficult. When writing code, you should give some care to your name choices because it will make your code more reasonable and readable. Using descriptive names to make it obvious what the object represents is the best technique to name your objects in Python. Cheers and sounds!


Author: Yang Wang
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source Yang Wang !
 Previous
Use SUBL Command in Windows Use SUBL Command in Windows
It's sometimes easier to edit a file from terminal by using Sublime Text, and yet it is not the default in Windows. This tutorial will show you how to use the command line to open files with Sublime Text in Windows.
2021-12-20
Next 
Alumni Profiles on Sheffield Website Alumni Profiles on Sheffield Website
I have recently been asked by my supervisor, Prof Chenghua Lin, to add my alumni profile to University of Sheffield website. There are some questions that has been asked I found it interesting, and I want to share them here.
2021-11-18
  TOC