Python Programming Style Guide

 

Code Structure

Python Style Guide

While Python is very flexible in terms of program and code structure, there are common practices related to structure or format of statements that should be followed, no matter the source language.

Boolean Literals

Typecasting

Splitting a String

Opening a File

Do not combine an input function as the argument to the open() function:

   inFile = open(input("Enter a filename: "))

Instead, this should be split into two separate instructions

filename = input("Enter a filename: ")
inFile = open(filename)

Storage Classes

  • Private versus Public



Python Style Guide
Print -- Recent Changes
Page last modified on April 22, 2012, at 03:54 PM