Python的50道陰影

48
Python 50 螇褞

Transcript of Python的50道陰影

Page 1: Python的50道陰影

Python 50

Page 2: Python的50道陰影

• Tim, Python

Page 3: Python的50道陰影

Page 4: Python的50道陰影
Page 5: Python的50道陰影
Page 6: Python的50道陰影
Page 7: Python的50道陰影

File "test.py", line 6 print "yoshi" ^IndentationError: unexpected indent

Page 8: Python的50道陰影

• Python Tab

• Tab

Page 9: Python的50道陰影
Page 10: Python的50道陰影

Parsing

pop pop

Page 11: Python的50道陰影

• Tab

• Editor Tab

Page 12: Python的50道陰影
Page 13: Python的50道陰影

default argument

Page 14: Python的50道陰影

• Python def argument

Page 15: Python的50道陰影
Page 16: Python的50道陰影

closure

Page 17: Python的50道陰影
Page 18: Python的50道陰影
Page 19: Python的50道陰影

• closure Python

• reference Python lexical scope)

• closure gc

Page 20: Python的50道陰影
Page 21: Python的50道陰影
Page 22: Python的50道陰影

• 1. class  __call__   lexical scope

• 2. functool.partial

Page 23: Python的50道陰影

Global Variable

Page 24: Python的50道陰影

• Python Local Global

Page 25: Python的50道陰影

global

local

Page 26: Python的50道陰影

• Global

• global

Page 27: Python的50道陰影
Page 28: Python的50道陰影

Dead or Alive

Page 29: Python的50道陰影
Page 30: Python的50道陰影
Page 31: Python的50道陰影

• del symbol table reference count -1

• reference count 0 GC, __del__

Page 32: Python的50道陰影

Circular reference

• 2016 Python

• __del__. Python

Page 33: Python的50道陰影

• circular reference. weak reference.

• weak reference reference count.

• Python gc

Page 34: Python的50道陰影

Interface

• interface

• base class Python

Page 35: Python的50道陰影
Page 36: Python的50道陰影
Page 37: Python的50道陰影

List Related

Page 38: Python的50道陰影

• iterate list

• list

Page 39: Python的50道陰影
Page 40: Python的50道陰影

Package

• sudo pip

• virtualenv

• requirements.txt dependency

• setup.py

Page 41: Python的50道陰影

• pip freeze > requirements.txt

• Conflict merge

Page 42: Python的50道陰影
Page 43: Python的50道陰影

2 == > 3• python 3

• __future__, six

• print_function

• absolute_import

• io.open 2.7 encoding

Page 44: Python的50道陰影

Quality

• flake8 —install-hook

• commit pep8

• # noqa

Page 45: Python的50道陰影

inheritance

• super

Page 46: Python的50道陰影
Page 47: Python的50道陰影
Page 48: Python的50道陰影

Any Question?