0% found this document useful (0 votes)
2 views2 pages

Python Programming Naming Standards

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Python Programming Naming Standards

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Introduction to Computer Science ICS Computer Studies

Programming Conventions and Standards


Rationale for Conventions (Industry Standards or Rules To Follow When Programming)
Programming conventions and standards are important in an environment where work is done in teams
and over a long time frame. Programs that follow a set of conventions are easier to read and update,
the following of conventions is a form of communication skill.

Most companies and post-secondary institutions have sets of standards and indeed in many post-
secondary situations, programs will NOT be marked if they do not follow local standards. Getting used
to following a set of conventions will help prepare you for further education and the workplace.

The Nature of Conventions


Conventions should be clear, consistent and not so lengthy that they are hard to follow. Conventions
should follow industry standards as often as possible as this will make resource books easier to
understand.

Documentation
Each program/file should start with a header block that specifies:
• Student Name
• Date (Month & Year)
• Program Identification (for example: [Link])
• Program Description (a small paragraph stating what the program does)

Example:

What is an identifier?
An identifier is anything that is given a name within a program. The term identifier is used as there is a
wider scope than variables that includes variables, methods, functions, and other objects.

Indenting
Every time a new structure is started, code should be indented. Nested structures means multiple
levels of indentation.

The best computer is your mind.


Introduction to Computer Science ICS Computer Studies

Python Naming Conventions Used In This Class


Python File Naming Convention
File names shall follow the capitalized words (CapWords) convention. Similar to camelCase, however
the first letter of each word shall be capital, including the first word (eg. NameCheck)

Function and Variable Naming Conventions


In the industry Python standard, function and variable names shall follow one of two conventions:
1. lower_case_with_underscores: All lower case letters, with embedded words separated by
an underscore character (eg. first_name)
2. camelCase: Begin with a lower case letter and be all lower case with the exception that
the first letter of any embedded word, which has a capital. This convention is often called
camel case (eg. firstName).

Constants should be upper case.

Variable Use Variable Name (similar for Functions)


The age of a person age
The first name of a person first_name or firstName
Total points total_points_earned or totalPointsEarned

Constants Naming Convention


Names of constants should be all uppercase, separated by underscores (eg. PI_VALUE = 3.14).

Class and Class Instance Naming Convention


Class and Class Instance names shall follow the capitalized words (CapWords) convention. Similar to
camelCase, however the first letter of each word shall be capital, including the first word (eg.
NameCheck)

Method Naming Convention


Method names shall follow the lower_case_with_underscores convention, similar to function names (eg.
name_check)

Python Project File/Folder Structure


When creating Python projects containing a [Link] program file and multiple class files, one should
follow one of the folder/file naming conventions shown below.

Option1 Option2

The best computer is your mind.

You might also like