Professional Documents
Culture Documents
Python in Entertainment Industry: Coding Style
Python in Entertainment Industry: Coding Style
Shuen-Huei Guan
Digimax Inc.
2009/06
Code Like a Pythonista: Idomatic Python
/* -- C -- */ # -- Python --
if (some condition) def myfunction(foo, bar):
if (some condition) foo.boing()
do_something(fancy); for i in bar.fizzle(foo):
else baz = i**2
this_sucks(badluck); foo.wibble(baz)
return foo, baz
/* -- another C -- */
if (condition)
somethingsExecuted();
alwaysExecuted(shouldNot);
alwaysExecuted();
tab size:2 tab size:3 tab size:4 tab size:8
“ 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
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