Skip to content

Instantly share code, notes, and snippets.

@ashwin
Created February 15, 2015 06:38
Show Gist options
  • Save ashwin/f00be797592c0052e51b to your computer and use it in GitHub Desktop.
Save ashwin/f00be797592c0052e51b to your computer and use it in GitHub Desktop.
Example of Google Python Style Guide
#!/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.
"""
__author__ = "Gamer Dude"
__email__ = "gamerdude@gmail.com"
__copyright__ = "Copyright 2015, Big Game Corp."
# Standard
import math
import sys
# External
import py_game_opengl
INVALID_MOVE = -1
class TicTacToe(object):
CELL_NUM = 9
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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment