개념
0. syntax
# : inline comment
""" : block comment
r'' : raw string
u'' : unicode string
--------
0. data type
[] : list
() : tuple (~ immutable list)
※ 1 element를 가진 tuple의 선언
(1,)
{} : dictionary
{,} : set
※ membership test : in, not in
※ index operation
※ slicing을 이용한 copying
newenum = enum[:]
--------
0. operation
* : product
** : power
'' '' : string literal concatenation
--------
0. function, arguments
packing : positional argument, keyword argument 형태로 argument를 받음
unpacking : container type data를 각 positional argument, keyword argument로 전달
list, tuple의 unpacking : *var
dict의 unpacking : **var
positional arguments
def foo(*args):
foo(one, two)
keyword arguments
def bar(**kwargs):
bar(one='one', two='two')
※ keyword argument가 position argument보다 앞에 정의될 수 없음
--------
0. lambda
list.sort(key=lambda i : i[y'])
--------
0. list comprehension
--------
0. Special methods
init(self, ...)
del(self)
str(self)
lt(self, other)
getitem(self, key)
len(self)
--------
0. Polymorphism
※ interface가 없다. abc를 대신 사용
import abc
class foo(object, metaclass=abc.ABCMeta):
@abc.abstractmethod
def bar(self):
pass
--------
0. Exception handling
raise
try except finally else
※ with as 구문
--------
0. Decorator
--------
0. References
https://mingrammer.com/understanding-the-asterisk-of-python/
https://docs.python.org/3/tutorial
--------
더 읽을 글
http://byteofpython-korean.sourceforge.net/byte_of_python.html
http://python-guide-kr.readthedocs.io/ko/latest/