python programming in entertainment industry: coding style

79
Shuen-Huei Guan Digimax Inc. 2009/06 Python Programming 101: Coding Style

Upload: shuen-huei-guan

Post on 05-Dec-2014

3.021 views

Category:

Technology


5 download

DESCRIPTION

In part 2 of python series (Python Programming in Entertainment Industry), we are talking about 6 basic coding style in python that would help RD/TD in animation/game studio that would help me a lot when they are doing more and more coding in the future.

TRANSCRIPT

Page 1: Python Programming in Entertainment Industry: Coding Style

Shuen-Huei Guan Digimax Inc. 2009/06

Python Programming 101: Coding Style

Page 2: Python Programming in Entertainment Industry: Coding Style
Page 3: Python Programming in Entertainment Industry: Coding Style

Code Like a Pythonista: Idomatic Python

Page 4: Python Programming in Entertainment Industry: Coding Style
Page 5: Python Programming in Entertainment Industry: Coding Style
Page 6: Python Programming in Entertainment Industry: Coding Style
Page 7: Python Programming in Entertainment Industry: Coding Style
Page 8: Python Programming in Entertainment Industry: Coding Style
Page 9: Python Programming in Entertainment Industry: Coding Style
Page 10: Python Programming in Entertainment Industry: Coding Style
Page 11: Python Programming in Entertainment Industry: Coding Style
Page 12: Python Programming in Entertainment Industry: Coding Style
Page 13: Python Programming in Entertainment Industry: Coding Style
Page 14: Python Programming in Entertainment Industry: Coding Style
Page 15: Python Programming in Entertainment Industry: Coding Style

/* -- C -- */

if (some condition)

if (some condition)

do_something(fancy);

else

this_sucks(badluck);

/* -- another C -- */

if (condition)

somethingsExecuted();

alwaysExecuted(shouldNot);

alwaysExecuted();

# -- Python --

def myfunction(foo, bar):

foo.boing()

for i in bar.fizzle(foo):

baz = i**2

foo.wibble(baz)

return foo, baz

Page 16: Python Programming in Entertainment Industry: Coding Style
Page 17: Python Programming in Entertainment Industry: Coding Style
Page 18: Python Programming in Entertainment Industry: Coding Style
Page 19: Python Programming in Entertainment Industry: Coding Style
Page 20: Python Programming in Entertainment Industry: Coding Style

tab size:2 tab size:3 tab size:4 tab size:8

Page 21: Python Programming in Entertainment Industry: Coding Style
Page 22: Python Programming in Entertainment Industry: Coding Style
Page 23: Python Programming in Entertainment Industry: Coding Style
Page 24: Python Programming in Entertainment Industry: Coding Style
Page 25: Python Programming in Entertainment Industry: Coding Style
Page 26: Python Programming in Entertainment Industry: Coding Style
Page 27: Python Programming in Entertainment Industry: Coding Style
Page 28: Python Programming in Entertainment Industry: Coding Style

“ general syntax on set modeline set ruler set autoindent “set smartindent “ search set hlsearch set incsearch set showmatch set ignorecase set smartcase “ mouse set mouse=a

Page 29: Python Programming in Entertainment Industry: Coding Style

autocmd BufRead *.py set sw=4 sts=4 et autocmd BufRead *.py set smartindent

cinwords=if,elif,else,for,while,try,except,finally,def,class

# vim: set sw=4 sts=4 et hls is si nu:

Page 30: Python Programming in Entertainment Industry: Coding Style

autocmd BufRead *.py set list listchars=tab:»_ # ref: http://vim.wikia.com/wiki/Highlight_unwanted_spaces

Page 31: Python Programming in Entertainment Industry: Coding Style
Page 32: Python Programming in Entertainment Industry: Coding Style
Page 33: Python Programming in Entertainment Industry: Coding Style
Page 34: Python Programming in Entertainment Industry: Coding Style
Page 35: Python Programming in Entertainment Industry: Coding Style
Page 36: Python Programming in Entertainment Industry: Coding Style
Page 37: Python Programming in Entertainment Industry: Coding Style
Page 38: Python Programming in Entertainment Industry: Coding Style
Page 39: Python Programming in Entertainment Industry: Coding Style
Page 40: Python Programming in Entertainment Industry: Coding Style
Page 41: Python Programming in Entertainment Industry: Coding Style
Page 42: Python Programming in Entertainment Industry: Coding Style
Page 43: Python Programming in Entertainment Industry: Coding Style
Page 44: Python Programming in Entertainment Industry: Coding Style
Page 45: Python Programming in Entertainment Industry: Coding Style
Page 46: Python Programming in Entertainment Industry: Coding Style
Page 47: Python Programming in Entertainment Industry: Coding Style
Page 48: Python Programming in Entertainment Industry: Coding Style
Page 49: Python Programming in Entertainment Industry: Coding Style
Page 50: Python Programming in Entertainment Industry: Coding Style
Page 51: Python Programming in Entertainment Industry: Coding Style
Page 52: Python Programming in Entertainment Industry: Coding Style
Page 53: Python Programming in Entertainment Industry: Coding Style
Page 54: Python Programming in Entertainment Industry: Coding Style
Page 55: Python Programming in Entertainment Industry: Coding Style
Page 56: Python Programming in Entertainment Industry: Coding Style
Page 57: Python Programming in Entertainment Industry: Coding Style
Page 58: Python Programming in Entertainment Industry: Coding Style
Page 59: Python Programming in Entertainment Industry: Coding Style
Page 60: Python Programming in Entertainment Industry: Coding Style
Page 61: Python Programming in Entertainment Industry: Coding Style
Page 62: Python Programming in Entertainment Industry: Coding Style
Page 63: Python Programming in Entertainment Industry: Coding Style
Page 64: Python Programming in Entertainment Industry: Coding Style
Page 65: Python Programming in Entertainment Industry: Coding Style
Page 66: Python Programming in Entertainment Industry: Coding Style

hello, world by oskay @ flickr.com

Page 67: Python Programming in Entertainment Industry: Coding Style
Page 68: Python Programming in Entertainment Industry: Coding Style
Page 69: Python Programming in Entertainment Industry: Coding Style
Page 70: Python Programming in Entertainment Industry: Coding Style
Page 71: Python Programming in Entertainment Industry: Coding Style
Page 72: Python Programming in Entertainment Industry: Coding Style
Page 73: Python Programming in Entertainment Industry: Coding Style
Page 74: Python Programming in Entertainment Industry: Coding Style
Page 75: Python Programming in Entertainment Industry: Coding Style

Jump to Conclusions mat by Katkreig @ flickr

Page 76: Python Programming in Entertainment Industry: Coding Style
Page 77: Python Programming in Entertainment Industry: Coding Style
Page 78: Python Programming in Entertainment Industry: Coding Style
Page 79: Python Programming in Entertainment Industry: Coding Style