📅 2015-Feb-15 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ google, python, style guide ⬩ 📚 Archive
I find it easy to grasp the Google Python Style Guide recommendations by creating a simple example, like this:
#!/usr/bin/env python
"""
Illustration of Google Python Style Guide:
https://google-styleguide.googlecode.com/svn/trunk/pyguide.html
This module provides a class to play TicTacToe game.
"""
= "Gamer Dude"
__author__ = "gamerdude@gmail.com"
__email__ = "Copyright 2015, Big Game Corp."
__copyright__
# Standard
import math
import sys
# External
import py_game_opengl
= -1
INVALID_MOVE
class TicTacToe(object):
= 9
CELL_NUM
def __init__(self):
"""
Game init method.
"""
self.cur_move = None
self.user_count = 0
self.board = [None for _ in range(CELL_NUM)]
self.renderer = py_game_opengl.Simple_Renderer()
self.renderer.init()
def make_move(self, pos, move):
"""
Make a move on the board.
"""
self.board[pos] = move
self.cur_move = move
self.renderer.draw(self.board)
def print_board(self):
"""
Print the cells of board.
"""
for i, move in enumerate(self.board):
print i, ":", move
def main():
print __doc__
if "__main__" == __name__:
main()