SlideShare a Scribd company logo
PythonIntermediateProgramming
임찬식(chanshik@gmail.com)
1
PythonIntermediateProgramming
타입과 객체
함수와함수형프로그래밍
클래스와객체지향프로그래밍
데이터구조
튜닝과 최적화
2
클래스와객체지향프로그래밍
class
클래스인스턴스
유효범위규칙
상속
다형성동적바인딩
3
class 문
클래스(class) 는인스턴스(instance) 라고 부르는객체에연결되고
이들객체사이에공유되는속성정의
일반적으로클래스는
함수(메서드), 변수(클래스변수), 계산된속성(프로퍼티) 을모아둔것
클래스는class 문으로정의하고 클래스몸체는
클래스가 정의되는도중에실행할문장을담고 있음
class 문자체는클래스의인스턴스를생성하지않음
클래스안에서정의되는함수를인스턴스메서드라부름
인스턴스메서드는첫번째인수로넘어오는클래스인스턴스에
대해서동작하는함수
첫번째인수이름은관례적으로self로사용
4
class 문
class Account(object):
num_accounts = 0
def __init__(self, name, balance):
self.name = name
self.balance = balance
Account.num_accounts += 1
def __del__(self):
Account.num_accounts -= 1
def deposit(self, amt):
self.balance = self.balance + amt
def withdraw(self, amt):
self.balance = self.balance - amt
def inquiry(self):
return self.balance
num_accounts 같은클래스변수는클래스의모든인스턴스에서공유
5
클래스인스턴스
클래스의인스턴스는클래스객체를함수로서호출해생성
새로운인스턴스는생성되고 클래스의__init__() 메서드에생성한
인스턴스를전달해초기화진행
>>> a = Account("Guido", 1000.00)
>>> a.balance
1000.0
>>> a.deposit(100.00)
>>> a.balance
1100.0
>>> Account.deposit(a, 100.00)
>>> a.balance
1200.0
6
클래스인스턴스
__init__() 안에서self에인스턴스속성추가하고
점(.) 연산자를사용해인스턴스나클래스속성에접근
def __init__(self, name, balance):
self.name = name # name 속성을 인스턴스에 추가
name속성에접근
>>> b = Account("Bill", 2000.00)
>>> b.name
'Bill'
점(.) 연산자를사용해속성에접근할때속성값을여러곳에서찾음
속성에접근하면먼저인스턴스를검사
인스턴스에없을경우에는클래스를검사
7
유효범위규칙
클래스는새로운네임스페이스를정의하지만메서드안에서참조하는
이름에대한유효범위를생성하지는않음
클래스메서를작성할때속성이나메서드에대한참조는인스턴스를
명확하게 지정하여야함
>>> class Foo(object):
... def bar(self):
... print("bar!")
... def spam(self):
... self.bar()
... Foo.bar(self)
... bar(self)
...
>>> Foo().spam()
bar!
bar!
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 7, in spam
NameError: name 'bar' is not defined 8
유효범위규칙
클래스에서유효범위가 생성되지않는점은C++ 혹은자바와다른점
C++ 이나자바에서this 포인터가 self매개변수와같음
파이썬에서변수를명시적으로선언할수있는방법이없기 때문에
메서드에서변수에값을대입할때self를이용
self.a = 10 # 인스턴스 변수 사용
a = 20 # 지역 변수 사용
9
상속
상속(inheritance)은기존클래스작동방식을특수화하거나변경하여
새로운클래스를생성하는방법
원본클래스: 기반클래스(baseclass) 또는상위클래스(superclass)
새클래스: 파생클래스(derivedclass) 또는하위클래스(subclass)
클래스가 상속을통해생성되면기반클래스에서정의된속성을그대로가짐
파생클래스는상속받은속성을제정의하거나자신만의새로운속성을정의
상송관계를지정하려면class 문에서기반클래스이름을콤마로구분해명시
특별한기반클래스가 없는경우에는object 로부터상속
object
모든파이썬객체의조상클래스이며공통메서드의기본구현제공
10
상속
상속을기존메서드작동방식을재정의하는데사용
>>> class SavingAccount(Account):
... def withdraw(self, amt):
... if self.balance - amt >= 0:
... self.balance -= amt
... else:
... raise ValueError("balance - amt < 0")
...
>>> s = SavingAccount("John", 10.00)
>>> s.deposit(10.0) # Account.deposit(s, 10.0)
>>> s.withdraw(30.0) # SavingAccount.withdraw(s, 30.0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 6, in withdraw
ValueError: balance must be greater than zero
11
상속
점(.) 연산자작동방식을약간 개선하여상속이구현됨
속성검색을수행할때인스턴스나클래스에서부합하는속성을찾지못하면
더찾아볼기반클래스가 없을때까지기반클래스에서속성검색을진행
s.withdraw() 는SavingAccount 클래스에정의된메서드호출
s.deposit() 은Account 클래스에정의된deposit() 메서드호출
하위클래스에서__init__() 를정의해인스턴스에새로운속성을
추가하는것이가능
하위클래스에서__init__() 정의하면
기반클래스__init__() 는자동으로호출되지않음
상위클래스__init__() 를호출해기반클래스를적절하게
초기화하는것은하위클래스의역할
12
상속
class SavingAccount(Account):
def __init__(self, name, balance, interest_rate):
Account.__init__(self, name, balance)
self.interest_rate = interest_rate
Account.__init__() 를호출해기반클래스초기화진행
기반클래스에서__init__() 를정의하였는지잘모를경우에는
단순히인수없이__init__() 를호출
‑> 항상아무일도하지않는기본구현이제공
13
상속
파생클래스에서어떤메서드를다시구현하였지만원래메서드구현을
호출할때는기반클래스메서드를직접호출하면서self전달
deposit() 메서드는Account 클래스에서구현되어있고
이메서드를호출하면서인스턴스self를전달해호출
class BasicSavingAccount(SavingAccount):
def deposit(self, amt):
self.withdraw(1.00) # 수수료 차감
SavingAccount.deposit(self, amt) # 기반 클래스 메서드
14
상속
기반클래스메서드를super() 함수를이용해호출하는방법
Python3
class BasicSavingAccount(SavingAccount):
def deposit(self, amt):
self.withdraw(1.00)
super().deposit(amt)
Python2
class BasicSavingAccount(SavingAccount):
def deposit(self, amt):
self.withdraw(1.00)
super(BasicSavingAccount, self).deposit(amt)
super(cls, instance) 는기반클래스에대해속성검색을수행하는
특수한객체를반환해어느기반클래스인지에상관없이메서드호출가능
15
다중상속
클래스에여러기반클래스를지정해다중상속(multipleinheritance) 사용
class DepositCharge(object):
fee = 1.00
def deposit_fee(self):
self.withdraw(self.fee) # self.fee 는 1.00 인가?
class WithdrawCharge(object):
fee = 2.00
def withdraw_fee(self):
self.withdraw(self.fee) # self.fee 는 2.00 인가?
class FreeSavingAccount(BasicSavingAccount,
DepositCharge, WithdrawCharge):
def deposit(self, amt):
self.deposit_fee()
super().deposit(amt)
def withdraw(self, amt):
super().withdraw(amt)
16
다중상속
>>> f = FreeSavingAccount("John", 100.0, 0.10)
>>> f.deposit_fee()
>>> f.balance
99.0 # 사용한 self.fee 는 1.00
>>> f.withdraw_fee()
>>> f.balance
98.0 # 사용한 self.fee 는 1.00
withdraw_fee() 메서드에서사용한self.fee는WithdrawCharge() 클래스
정의에있는값이아니라DepositCharge() 클래스에정의된값
17
다중상속
어떤클래스의기반클래스접근 순서를확인하려면__mro__ 속성확인
(MethodResolutionOrder)
>>> FreeSavingAccount.__mro__
(<class '__main__.FreeSavingAccount'>,
<class '__main__.BasicSavingAccount'>,
<class '__main__.SavingAccount'>,
<class '__main__.Account'>,
<class '__main__.DepositCharge'>,
<class '__main__.WithdrawCharge'>,
<class 'object'>)
기반클래스순서는일반적으로
파생클래스는항상기반클래스보다먼저검사
다중상속인경우에는클래스정의에나와있는순서대로검사
18
다중상속
기반클래스검사순서를명확하게 하기 힘든경우에는클래스생성불가
>>> class X(object):
... pass
...
>>> class Y(X):
... pass
...
>>> class Z(X, Y):
... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Cannot create a consistent method resolution
order (MRO) for bases X, Y
19
다중상속
클래스Z에서기반클래스순서를제대로정할수없기 때문에TypeError
클래스X는클래스Y보다먼저나타나기 때문에먼저검사
클래스Y는클래스X에서상속을받았기 때문에더특화된클래스
X가 먼저검사된다면Y에서특수화된메서드를검색하는건 불가능함
일반적으로이러한문제가 발생한다는것은프로그램설계에
문제가 있다는신호일경우가 많으니설계 부분을다시검토하는것이좋음
다중상속자체는가급적사용하지않는것이좋으나
혼합클래스(mixinclass) 를정의할때종종사용함
DepositCharge, WithdrawCharge에서는또다른메서드가 있다고
가정하고 그 메서드들을이용하는형태로작성
20
다형성동적바인딩과 오리타입화
동적바인딩(dynamicbinding)은타입에신경 쓰지않고 인스턴스를
사용하는객체지향언어의특징
동적바인딩은상속과 관련된속성검색과정을통해이루어짐
obj.attr 을통해속성에접근하면
먼저인스턴스자체에서attr 검색
못찾을경우인스턴스의클래스정의에서검색
그래도못찾을경우에는기반클래스에서검색
이중에서가장먼저검색된속성이반환되어이용
21
다형성동적바인딩과 오리타입화
동적으로속성을바인딩하는과정은객체가 실제로어떤타입인지상관없음
obj.name같은속성검색은name속성을갖고 있는객체라면
어떤객체인지에관계없이동작하고 이것을오리타입화라부름
오리타입화(ducktyping)
"오리처럼생겼고, 오리처럼울고, 오리처럼걸으면그것은오리이다"
기존객체를수정하려면기존객체에서상속을받아변경하는것도가능하고
기존객체와관련이없지만기존객체처럼보이는객체를생성하는것도가능
오리타입화를이용해구성요소들사이에느슨한결합을가진형태로
동작하는프로그램을설계하는것이가능
파일처럼동작하는객체들은내장파일객체와아무런관계가 없이
겉에서보면파일처럼사용할수있음
22
정적메서드와클래스메서드
정적메서드(staticmethod) 는클래스에의해정의되는네임스페이스에
포함되어있는일반함수를나타냄
정적메서드는인스턴스에대해서동작하지않음
@staticmethod장식자를이용해정의
인스턴스를받지않으므로self인수를정의하지않음
>>> class Foo(object):
... @staticmethod
... def add(x, y):
... return x + y
...
>>> Foo.add(1, 2)
3
>>> Foo.add(3, 4)
7
>>>
정적메서드는다양한방식으로인스턴스를생성하는클래스를작성할때활용 23
정적메서드와클래스메서드
>>> import time
>>> class Date(object):
... def __init__(self, year, month, day):
... self.year = year
... self.month = month
... self.day = day
... @staticmethod
... def now():
... t = time.localtime()
... return Date(t.tm_year, t.tm_mon, t.tm_mday)
... @staticmethod
... def tomorrow():
... t = time.localtime(time.time() + 86400)
... return Date(t.tm_year, t.tm_mon, t.tm_mday)
...
>>> d = Date(2017, 1, 1)
>>> d.year, d.month, d.day
(2017, 1, 1)
>>> now = Date.now()
>>> now.year, now.month, now.day
(2017, 1, 17)
24
정적메서드와클래스메서드
클래스메서드(class method) 는클래스자체를객체로보고
클래스객체에대해동작하는메서드
@classmethod장식자를사용해서정의
첫번째인수로cls 라는이름을가진클래스가 전달
>>> class Times(object):
... factor = 1
... @classmethod
... def mul(cls, x):
... return cls.factor * x
...
>>>
>>> class TwoTimes(Times):
... factor = 2
...
>>> TwoTimes.mul(2) # Times.mul(TwoTimes, 2) 호출
4
>>> TwoTimes.mul(4) # Times.mul(TwoTimes, 4) 호출
8
25
정적메서드와클래스메서드
Date클래스를상속받아새로운EuroDate클래스생성
>>> class EuroDate(Date):
... def __str__(self):
... return "%02d/%02d/%04d" % (self.day,
... self.month,
... self.year)
...
>>> e = EuroDate(2017, 1, 1)
>>> type(e)
<class '__main__.EuroDate'>
>>> print(e)
01/01/2017
>>> now = EuroDate.now()
>>> type(now)
<class '__main__.Date'>
>>> print(now)
<__main__.Date object at 0x10be039e8>
26
정적메서드와클래스메서드
EuroDate.now(), EuroDate.tomorrow() 에서반환하는객체는
EuroDate가 아닌Date클래스객체
이러한문제를클래스메서드를사용해해결
>>> class Date(object):
... def __init__(self, year, month, day):
... self.year = year
... self.month = month
... self.day = day
... @classmethod
... def now(cls):
... t = time.localtime()
... return cls(t.tm_year, t.tm_mon, t.tm_mday)
... @classmethod
... def tomorrow(cls):
... t = time.localtime(time.time() + 86400)
... return cls(t.tm_year, t.tm_mon, t.tm_mday)
...
27
정적메서드와클래스메서드
>>> class Date(object):
... def __init__(self, year, month, day):
... self.year = year
... self.month = month
... self.day = day
... def __str__(self):
... return "%04d-%02d-%02d" % (self.year,
self.month, self.day)
... @classmethod
... def now(cls):
... t = time.localtime()
... return cls(t.tm_year, t.tm_mon, t.tm_mday)
... @classmethod
... def tomorrow(cls):
... t = time.localtime(time.time() + 86400)
... return cls(t.tm_year, t.tm_mon, t.tm_mday)
...
>>> print(Date.now())
2017-01-17
>>> print(EuroDate.now())
17/01/2017
28
정적메서드와클래스메서드
파이썬에서는정적메서드와클래스메서드를인스턴스메서드와
별도네임스페이스로관리하지않음
네임스페이스가 다르지않기 때문에인스턴스에서
정적, 클래스메서드를호출하는것이가능
>>> d = Date(2017, 1, 1)
>>> now = d.now()
>>> print(now)
2017-01-18
29
프로퍼티
프로퍼티(property) 는접근하는순간 값을계산하는특수한속성
>>> import math
>>> class Circle(object):
... def __init__(self, radius):
... self.radius = radius
... @property
... def area(self):
... return math.pi * self.radius ** 2
... @property
... def perimeter(self):
... return 2 * math.pi * self.radius
...
>>> c = Circle(2.0)
>>> c.radius
2.0
30
프로퍼티
장식자@property 를이용해바로다음에나오는메서드를
"()" 없이단순속성인것처럼접근
>>> c.area
12.566370614359172
>>> c.perimeter
12.566370614359172
>>> c.area = 10
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: can't set attribute
속성을재정의하려고 시도할경우AttributeError 발생
31
프로퍼티
균일접근 원칙(uniformaccess principle)
클래스를정의할때단순속성과 메서드를이용한속성이모두존재할경우
단순속성에접근할때는c.radius
메서드속성에접근할때는c.area()
이렇게 언제"()"를붙여주어야하는지기억하는불편함을줄이기 위해
프로퍼티를사용할수있음
32
프로퍼티
프로퍼티를설정하거나삭제하는메서드
>>> class Foo(object):
... def __init__(self, name):
... self.__name = name
... @property
... def name(self):
... return self.__name
... @name.setter
... def name(self, value):
... if not isinstance(value, str):
... raise TypeError("Must be a string")
... self.__name = value
... @name.deleter
... def name(self):
... raise TypeError("Can't delete name")
...
33
프로퍼티
>>> f = Foo("John")
>>> f.name = "Jane"
>>> f.name = 42
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 10, in name
TypeError: Must be a string
>>> del f.name
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 14, in name
TypeError: Can't delete name
속성name은@property 장식자를이용해읽기 전용프로퍼티로정의
@name.setter 는설정을위한추가 메서드연결
@name.deleter 는삭제를위한추가 메서드연결
추가 메서드는원본프로퍼티이름과 동일
34
데이터캡슐화와private속성
파이썬에서는클래스의모든속성과 메서드가 그대로노출되어
파생클래스와기반클래스사이에이름충돌이발생가능
이름변형(namemangling)
이문제를해결하기 위해클래스에서__Foo같은이중밑줄로시작하는
모든이름을자동으로_클래스이름__Foo의형태로변환
파생클래스에서사용하는private이름과 기반클래스에서사용하는
이름이충돌하지않음
클래스에서사용하는private속성과 메서드를정의하는것이가능
35
데이터캡슐화와private속성
class A(object):
def __init__(self):
self.__X = 3 # self._A__X 로 변형
def __spam(self): # _A__spam() 으로 변형
print(self.__X)
def bar(self):
self.__spam()
class B(A):
def __init__(self):
A.__init__(self)
self.__X = 37 # self._B__X 로 변형
def __spam(self): # _B__spam() 으로 변형
print(self.__X)
def bar(self):
self.__spam()
36
데이터캡슐화와private속성
속성과 메서드이름을변형하여도클래스private속성에접근하는것을
근본적으로막을방법은없음
클래스이름과 속성을알고 있으면변형된이름을사용해접근 가능
>>> a = A()
>>> a.bar()
3
>>> b = B()
>>> b.bar()
37
>>> dir(b)
['_A__X', '_A__spam', '_B__X', '_B__spam', '__class__', ...
>>> b._A__X
3
37
객체메모리관리
인스턴스생성은새로운인스턴스를생성하는특수메서드__new__() 와
생성된인스턴스를초기화하는__init__() 메서드를통해수행
>>> class Circle(object):
... def __init__(self, radius):
... self.radius = radius
...
>>> c = Circle(2.0)
>>>
>>> d = Circle.__new__(Circle, 2.0)
>>> if isinstance(c, Circle):
... Circle.__init__(c, 2.0)
>>>
>>> c.radius
2.0
>>> d.radius
2.0
...
38
객체메모리관리
클래스의__new__() 메서드를사용자코드에서재정의하는경우는매우희박
메서드를재정의할때는일반적으로__new__(cls, *args, **kwargs) 형태
클래스에서__new__() 를정의하여사용하는경우
변경이불가능한기반클래스로부터상속을받는경우
정수, 문자열, 튜플등과 같은내장타입에서상속을받은객체정의
인스턴스가 생성되기 전에실행되는__new__() 에서값을변경
>>> class UpperStr(str):
... def __new__(cls, value=""):
... return str.__new__(cls, value.upper())
...
>>> s = UpperStr("Hello, World!")
>>> s
'HELLO, WORLD!'
메타클래스를정의하기 위해
39
객체메모리관리
인스턴스를파괴하기 전에인터프리터는먼저인스턴스에
__del__() 메서드가 있는지확인후존재하면호출
del문이참조횟수를줄이고 이값이0이되면__del__() 메서드호출
close() 같은메서드를두어서명시적인마무리작업을
직접수행할수있는형태로구성하는것이바람직
40
객체표현과 속성바인딩
인스턴스는내부적으로__dict__ 속성으로접근할수있는사전을이용해구현
__dict__ 속성에는각 인스턴스가 가지고 있는고유한데이터를저장
>>> a = Account('Bill', 2000.0)
>>> a.__dict__
{'name': 'Bill', 'balance': 2000.0}
>>> a.number=1
>>> a.__dict__
{'name': 'Bill', 'balance': 2000.0, 'number': 1}
언제든지인스턴스에새로운속성을추가하는것이가능하고
이변화는항상내부__dict__ 에반영
41
객체표현과 속성바인딩
인스턴스는특수한속성__class__ 를통해자신의클래스에연결
클래스자체도__dict__ 속성을가지고 있고 이속성안에
클래스자체에대한정보와메서드정보를저장
>>> a.__class__
<class '__main__.Account'>
>>> Account.__dict__.keys()
dict_keys(['__module__', 'num_accounts', '__init__',
'__del__', 'deposit', 'withdraw', 'inquiry',
'__dict__', '__weakref__', '__doc__'])
42
객체표현과 속성바인딩
클래스는기반클래스들을담는__bases__ 튜플속성을통해
자신의기반클래스에연결됨
>>> FreeSavingAccount.__bases__
(<class '__main__.BasicSavingAccount'>,
<class '__main__.DepositCharge'>,
<class '__main__.WithdrawCharge'>)
43
객체표현과 속성바인딩
obj.name= value로속성을설정할때마다특수메서드
obj.__setattr__("name", value) 가 호출
delobj.name으로속성을삭제하면특수메서드
obj.__delattr__("name") 가 호출
obj.name같은속성을검색할때에는특수메서드
obj.__getattribute__("name") 가 호출
obj.__getattribute__() 메서드검색순서
내부프로퍼티
내부__dict__
클래스__dict__
기반클래스들내부검색
클래스의__getattr__() 메서드
이모든곳에서찾지못하면AttributeError 발생 44
객체표현과 속성바인딩
사용자정의클래스에서속성검색함수를이용한구현방법예
class Circle(object):
def __init__(self, radius):
self.radius = radius
def __getattr__(self, name):
if name == 'area':
return math.pi * self.radius ** 2
elif name == 'perimeter':
return 2 * math.pi * self.radius
else:
return object.__getattribute__(self, name)
def __setattr__(self, name, value):
if name in ['area', 'perimeter']:
raise TypeError("%s is readonly" % name)
object.__setattr__(self, name, value)
45
객체표현과 속성바인딩
>>> c = Circle(2.0)
>>> c.area
12.566370614359172
>>> c.perimeter
12.566370614359172
>>> c.name = "Circle"
>>> c.area = 20
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 13, in __setattr__
TypeError: area is readonly
46
__slots__
클래스에서__slots__ 특수변수를정의해속성이름을제한할수있음
class Stock(object):
__slots__ = ("name", "qty")
def __init__(self, name, qty):
self.name = name
self.qty = qty
지정된속성이외의이름을사용하면AttributeError 발생
>>> s = Stock("pen", 100)
>>> s.tag = "pen"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Stock' object has no attribute 'tag'
47
__slots__
일반적으로__slots__ 은속성보호기능보다는메모리와실행속도를
최적화하기 위한용도로사용
__slots__ 을사용하는클래스인스턴스는인스턴스데이터를저장하는데
사전을사용하지않고 배열에기초한간결한데이터구조를사용
__slots__ 을사용하는기반클래스로부터상속을받으면
자신또한__slots__ 을정의할필요가 있음
인스턴스내부__dict__ 속성을직접사용하는코드가 있다면
제대로동작하지않을수있음
48
연산자오버로딩
연산자오버로딩을위해서는클래스에__add__() 같은특수메서드를정의
복소수를나타내는클래스예(내장객체에복소수는이미있음)
class Complex(object):
def __init__(self, real, imag=0):
self.real = float(real)
self.imag = float(imag)
def __repr__(self):
return "Complex(%s, %s)" % (self.real, self.imag)
def __str__(self):
return "(%g+%gj)" % (self.real, self.imag)
def __add__(self, other):
return Complex(self.real + other.real,
self.imag + other.imag)
def __sub__(self, other):
return Complex(self.real - other.real,
self.imag - other.imag)
49
연산자오버로딩
__repr__()
평가될경우객체를다시만들기 위한문자열생성
__str__()
print() 문에의해서출력될문자열생성
__add__()
복소수가 "+" 연산자왼쪽에나올때호출되는메서드
__sub__()
복소수가 "‑" 연산자왼쪽에나올때호출되는메서드
앞에서구현한연산자메서드는연산자의오른쪽에위치하거나
제일왼쪽피연산자가 Complex 가 아닐경우에는제대로동작하지않음
50
연산자오버로딩
>>> a = Complex(3, 2)
>>> b = Complex(2, 3)
>>> a + b
Complex(5.0, 5.0)
>>> a + 4.0
Complex(7.0, 2.0)
>>> 4.0 + a
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +:
'float' and 'Complex'
파이썬내장숫자에는.real, .imag속성이존재하기 때문에"+" 연산이동작
Complex 구현이다른객체와도동작하도록하기 위해서는other 객체타입에
따라필요한속성을추출하는코드가 더필요
51
연산자오버로딩
>>> 4.0 + a
위코드에서내장부동소수점타입은Complex 클래스를전혀모르기 때문에
제대로동작하지않음
이러한문제를해결하기 위해Complex 클래스에역피연산자메서드추가
...
def __radd__(self, other):
return Complex(self.real + other.real,
self.imag + other.imag)
def __rsub__(self, other):
return Complex(self.real - other.real,
self.imag - other.imag)
...
>>> a = Complex(3, 2)
>>> 4.0 + a
Complex(7.0, 2.0)
52
타입과 클래스멤버검사
isinstance(obj, cname)
특정인스턴스가 어떤클래스에속하는지를검사하는내장함수
객체obj가 클래스cname이나cname에서파생된클래스에속하면True
class A(object): pass
class B(A): pass
class C(object):pass
>>> type(a)
<class '__main__.A'>
>>> isinstance(a, A)
True
>>> isinstance(b, A)
True
>>> isinstance(b, C)
False
53
타입과 클래스멤버검사
issubclass(A, B)
클래스A 가 클래스B 의하위클래스일경우True를반환
>>> issubclass(B, A)
True
>>> issubclass(C, A)
False
54
타입과 클래스멤버검사
실제상속관계를가지지않고 동일한메서드를구현하여다른객체를
흉내내는방식으로구성한클래스의타입검사방법
class Foo(object):
def spam(self, a, b):
pass
class FooProxy(object):
def __init__(self, f):
self.f = f
def spam(self, a, b):
return self.f.spam(a, b)
위두클래스는기능적으로동일하지만타입시스템상에서는서로다름
>>> f = Foo()
>>> g = FooProxy(f)
>>> isinstance(g, Foo)
False
55
타입과 클래스멤버검사
어떤객체가 Foo와동일한인터페이스를가지고 있다면Foo처럼
사용될수있도록비슷한객체들을그룹지어검사할수있도록
isinstance(), issubclass() 를재정의
class IClass(object):
def __init__(self):
self.implementors = set()
def register(self, C):
self.implementors.add(C)
def __subclasscheck__(self, sub):
return any(c in self.implementors
for c in sub.mro())
def __instancecheck__(self, x):
return self.__subclasscheck__(type(x))
56
타입과 클래스멤버검사
클래스IClass 는집합자료구조를사용해클래스들을그룹짓는객체생성
register(): 집합에새로운클래스추가
__instancecheck__(): isinstance연산을수행할때호출
__subclasscheck__(): issubclass 연산을수행할때호출
IFoo객체와등록된객체들을이용해타입검사수행
>>> IFoo = IClass()
>>> IFoo.register(Foo)
>>> IFoo.register(FooProxy)
>>> f = Foo()
>>> g = FooProxy(f)
>>> isinstance(f, IFoo)
True
>>> isinstance(g, IFoo)
True
>>> issubclass(FooProxy, IFoo)
True
57
추상기반클래스
추상기반클래스(abstract baseclass)
객체들을계층으로구성하거나필수메서드를강제하는작업가능
abc모듈을사용해추상기반클래스정의
ABCMeta, @abstractmethod, @abstractproperty 등을이용
class Foo: # Python 2
__metaclass__ = ABCMeta
from abc import ABCMeta, abstractmethod, abstractproperty
class Foo(metaclass=ABCMeta): # Python 3
@abstractmethod
def spam(self, a, b):
pass
@abstractproperty
def name(self):
pass
58
추상기반클래스
추상클래스를정의할때는ABCMeta를클래스의메타클래스로설정
추상클래스안에서@abstractmethod, @abstractproperty 장식자를
이용해Foo하위클래스에서반드시구현하도록강제
>>> f = Foo()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Can't instantiate abstract class Foo with
abstract methods name, spam
Foo클래스인스턴스는바로생성할수없고 하위클래스에서필요한
메서드와프로퍼티를구현해야생성가능
59
추상기반클래스
추상기반클래스는반드시구현해야하는메서드나프로퍼티에대한
규칙을검사하지만인수나반환값에대해서는검사하지않음
하위클래스메서드인수가 추상메서드인수와동일한지
하위클래스프로퍼티가 추상프로퍼티와동일한연산을지원하는지
두가지경우모두검사를진행하지않음
60
추상기반클래스
추상기반클래스는기존클래스를등록하는기능제공
class Grok(object):
def spam(self, a, b):
print("Grok.spam")
register() 메서드를이용해클래스등록
>>> Foo.register(Grok)
<class '__main__.Grok'>
>>> g = Grok()
>>> isinstance(g, Foo)
True
클래스가 추상클래스에등록되면실제로추상메서드나프로퍼티를
구현하고 있는지를검사하지않고 단순히타입검사에만영향
61
메타클래스
파이썬에서클래스를정의하면클래스정의자체도객체로취급
>>> class Foo(object):
... pass
...
>>> isinstance(Foo, object)
True
메타클래스(metaclass)
클래스를어떻게 생성하고 관리하는지를알고 있는객체를뜻함
위에예에서는Foo생성을제어하는메타클래스는type클래스
>>> type(Foo)
<class 'type'>
62
메타클래스
class 문으로새로운클래스를정의할때일어나는일
클래스몸체안에있는문장이private사전안에서실행
private멤버이름변형
클래스객체를생성하기 위해이름, 기반클래스목록, 생성된사전이
메타클래스생성자에전달
메타클래스type() 이호출되는마지막단계를변경하는방법
클래스를정의할때metaclass 지정
class Foo(metaclass=type) # Python 3
class Foo: __metaclass__ = type # Python 2
기반클래스목록튜플에metaclass 키워드인수전달
63
메타클래스
메타클래스를명시적으로지정하지않을경우
기반클래스들의튜플에서첫번째항목선택(존재할경우)
기반클래스를지정하지않으면__metaclass__ 전역변수탐색
__metaclass__ = type
class Foo:
pass
아무것도못찾으면기본메타클래스사용
Python2: types.ClassType
Python3: type()
64
메타클래스
메타클래스는객체를정의하는방식에제약을가하고자할때주로사용
모든메서드에문서화문자열이존재해야하는것을강제하는메타클래스예
class DocMeta(type):
def __init__(self, name, bases, attrs):
for key, value in attrs.items():
# 특수 메서드와 private 메서드는 넘어감
if key.startswith("__"):
continue
# 호출 가능하지 않은 것은 넘어감
if not hasattr(value, "__call__"):
continue
# 문서화 문자열을 가지고 있는지 검사
if not getattr(value, "__doc__"):
raise TypeError(
"%s must have a docstring" % key)
type.__init__(self, name, bases, attrs)
65
메타클래스
앞에서정의한메타클래스를이용한기반클래스정의
Python3
class Documented(metaclass=DocMeta):
pass
Python2
class Documented:
__metaclass__ = DocMeta
66
메타클래스
문서화가 필요한클래스기반클래스로Documented지정
>>> class Foo(Documented):
... def spam(self, a, b):
... print("spam")
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 11, in __init__
TypeError: spam must have a docstring
67
클래스장식자
클래스장식자(decorator)
클래스생성과정전체를관여하기 보다단순히클래스정의후에
단순하게 몇가지추가 작업을수행하고자할때사용
registry = {}
def register(cls):
registry[cls.__clsid__] = cls
return cls
클래스정의앞에장식자이용
@register
class Foo(object):
__clsid__ = "111-111"
def bar(self):
pass
68
클래스장식자
클래스를정의하며registry 객체에등록
>>> @register
... class Foo(object):
... __clsid__ = "111-111"
... def bar(self):
... pass
...
>>> registry
{'111-111': <class '__main__.Foo'>}
69

More Related Content

What's hot

파이썬 Collections 모듈 이해하기
파이썬 Collections 모듈 이해하기파이썬 Collections 모듈 이해하기
파이썬 Collections 모듈 이해하기
Yong Joon Moon
 
파이썬+함수이해하기 20160229
파이썬+함수이해하기 20160229파이썬+함수이해하기 20160229
파이썬+함수이해하기 20160229
Yong Joon Moon
 
파이썬 namespace Binding 이해하기
파이썬 namespace Binding 이해하기 파이썬 namespace Binding 이해하기
파이썬 namespace Binding 이해하기
Yong Joon Moon
 
파이썬 Special method 이해하기
파이썬 Special method 이해하기파이썬 Special method 이해하기
파이썬 Special method 이해하기
Yong Joon Moon
 
파이썬 class 및 function namespace 이해하기
파이썬 class 및 function namespace 이해하기파이썬 class 및 function namespace 이해하기
파이썬 class 및 function namespace 이해하기
Yong Joon Moon
 
파이썬+Operator+이해하기 20160409
파이썬+Operator+이해하기 20160409파이썬+Operator+이해하기 20160409
파이썬+Operator+이해하기 20160409
Yong Joon Moon
 
파이썬+Json+이해하기 20160301
파이썬+Json+이해하기 20160301파이썬+Json+이해하기 20160301
파이썬+Json+이해하기 20160301
Yong Joon Moon
 
Python+numpy pandas 4편
Python+numpy pandas 4편Python+numpy pandas 4편
Python+numpy pandas 4편
Yong Joon Moon
 
Jupyter notebook 이해하기
Jupyter notebook 이해하기 Jupyter notebook 이해하기
Jupyter notebook 이해하기
Yong Joon Moon
 
파이썬 심화
파이썬 심화파이썬 심화
파이썬 심화
Yong Joon Moon
 
파이썬 함수 이해하기
파이썬 함수 이해하기 파이썬 함수 이해하기
파이썬 함수 이해하기
Yong Joon Moon
 
파이썬 반복자 생성자 이해하기
파이썬 반복자 생성자 이해하기파이썬 반복자 생성자 이해하기
파이썬 반복자 생성자 이해하기
Yong Joon Moon
 
파이썬 프로퍼티 디스크립터 이해하기
파이썬 프로퍼티 디스크립터 이해하기파이썬 프로퍼티 디스크립터 이해하기
파이썬 프로퍼티 디스크립터 이해하기
Yong Joon Moon
 
Smalltalk at Altlang 2008
Smalltalk at Altlang 2008Smalltalk at Altlang 2008
Smalltalk at Altlang 2008daliot
 
Python+numpy pandas 1편
Python+numpy pandas 1편Python+numpy pandas 1편
Python+numpy pandas 1편
Yong Joon Moon
 
Reflect package 사용하기
Reflect package 사용하기Reflect package 사용하기
Reflect package 사용하기
Yong Joon Moon
 
Python array.array 모듈 이해하기
Python array.array 모듈 이해하기Python array.array 모듈 이해하기
Python array.array 모듈 이해하기
Yong Joon Moon
 
파이썬 iterator generator 이해하기
파이썬 iterator generator 이해하기파이썬 iterator generator 이해하기
파이썬 iterator generator 이해하기
Yong Joon Moon
 
파이썬 크롤링 모듈
파이썬 크롤링 모듈파이썬 크롤링 모듈
파이썬 크롤링 모듈
Yong Joon Moon
 
엘라스틱서치 이해하기 20160612
엘라스틱서치 이해하기 20160612엘라스틱서치 이해하기 20160612
엘라스틱서치 이해하기 20160612
Yong Joon Moon
 

What's hot (20)

파이썬 Collections 모듈 이해하기
파이썬 Collections 모듈 이해하기파이썬 Collections 모듈 이해하기
파이썬 Collections 모듈 이해하기
 
파이썬+함수이해하기 20160229
파이썬+함수이해하기 20160229파이썬+함수이해하기 20160229
파이썬+함수이해하기 20160229
 
파이썬 namespace Binding 이해하기
파이썬 namespace Binding 이해하기 파이썬 namespace Binding 이해하기
파이썬 namespace Binding 이해하기
 
파이썬 Special method 이해하기
파이썬 Special method 이해하기파이썬 Special method 이해하기
파이썬 Special method 이해하기
 
파이썬 class 및 function namespace 이해하기
파이썬 class 및 function namespace 이해하기파이썬 class 및 function namespace 이해하기
파이썬 class 및 function namespace 이해하기
 
파이썬+Operator+이해하기 20160409
파이썬+Operator+이해하기 20160409파이썬+Operator+이해하기 20160409
파이썬+Operator+이해하기 20160409
 
파이썬+Json+이해하기 20160301
파이썬+Json+이해하기 20160301파이썬+Json+이해하기 20160301
파이썬+Json+이해하기 20160301
 
Python+numpy pandas 4편
Python+numpy pandas 4편Python+numpy pandas 4편
Python+numpy pandas 4편
 
Jupyter notebook 이해하기
Jupyter notebook 이해하기 Jupyter notebook 이해하기
Jupyter notebook 이해하기
 
파이썬 심화
파이썬 심화파이썬 심화
파이썬 심화
 
파이썬 함수 이해하기
파이썬 함수 이해하기 파이썬 함수 이해하기
파이썬 함수 이해하기
 
파이썬 반복자 생성자 이해하기
파이썬 반복자 생성자 이해하기파이썬 반복자 생성자 이해하기
파이썬 반복자 생성자 이해하기
 
파이썬 프로퍼티 디스크립터 이해하기
파이썬 프로퍼티 디스크립터 이해하기파이썬 프로퍼티 디스크립터 이해하기
파이썬 프로퍼티 디스크립터 이해하기
 
Smalltalk at Altlang 2008
Smalltalk at Altlang 2008Smalltalk at Altlang 2008
Smalltalk at Altlang 2008
 
Python+numpy pandas 1편
Python+numpy pandas 1편Python+numpy pandas 1편
Python+numpy pandas 1편
 
Reflect package 사용하기
Reflect package 사용하기Reflect package 사용하기
Reflect package 사용하기
 
Python array.array 모듈 이해하기
Python array.array 모듈 이해하기Python array.array 모듈 이해하기
Python array.array 모듈 이해하기
 
파이썬 iterator generator 이해하기
파이썬 iterator generator 이해하기파이썬 iterator generator 이해하기
파이썬 iterator generator 이해하기
 
파이썬 크롤링 모듈
파이썬 크롤링 모듈파이썬 크롤링 모듈
파이썬 크롤링 모듈
 
엘라스틱서치 이해하기 20160612
엘라스틱서치 이해하기 20160612엘라스틱서치 이해하기 20160612
엘라스틱서치 이해하기 20160612
 

Viewers also liked

Python Programming: Tuning and Optimization
Python Programming: Tuning and OptimizationPython Programming: Tuning and Optimization
Python Programming: Tuning and Optimization
Chan Shik Lim
 
Python Programming: Data Structure
Python Programming: Data StructurePython Programming: Data Structure
Python Programming: Data Structure
Chan Shik Lim
 
Python Programming: Function
Python Programming: FunctionPython Programming: Function
Python Programming: Function
Chan Shik Lim
 
Python programming for Bioinformatics
Python programming for BioinformaticsPython programming for Bioinformatics
Python programming for Bioinformatics
Hyungyong Kim
 
H3 2011 모바일에서의 Location API 완전정복
H3 2011 모바일에서의 Location API 완전정복H3 2011 모바일에서의 Location API 완전정복
H3 2011 모바일에서의 Location API 완전정복KTH
 
Cybercrime in Russia: Trends and Issues
Cybercrime in Russia: Trends and IssuesCybercrime in Russia: Trends and Issues
Cybercrime in Russia: Trends and Issues
Alex Matrosov
 
『고성능 파이썬』 - 맛보기
『고성능 파이썬』 - 맛보기『고성능 파이썬』 - 맛보기
『고성능 파이썬』 - 맛보기
복연 이
 
Understanding the black hat hacker eco system
Understanding the black hat hacker eco systemUnderstanding the black hat hacker eco system
Understanding the black hat hacker eco system
David Sweigert
 
H3 2011 파이썬으로 클라우드 하고 싶어요
H3 2011 파이썬으로 클라우드 하고 싶어요H3 2011 파이썬으로 클라우드 하고 싶어요
H3 2011 파이썬으로 클라우드 하고 싶어요KTH
 
Pycon2016 파이썬으로똑똑한주식투자 김대현
Pycon2016 파이썬으로똑똑한주식투자 김대현Pycon2016 파이썬으로똑똑한주식투자 김대현
Pycon2016 파이썬으로똑똑한주식투자 김대현
Daehyun (Damon) Kim
 
Object-oriented Programming in Python
Object-oriented Programming in PythonObject-oriented Programming in Python
Object-oriented Programming in Python
Juan-Manuel Gimeno
 
금융 데이터 이해와 분석 PyCon 2014
금융 데이터 이해와 분석 PyCon 2014금융 데이터 이해와 분석 PyCon 2014
금융 데이터 이해와 분석 PyCon 2014
Seung-June Lee
 
Risks to Cloud based critical infrastructure -- DHS bulletin
Risks to Cloud based critical infrastructure -- DHS bulletinRisks to Cloud based critical infrastructure -- DHS bulletin
Risks to Cloud based critical infrastructure -- DHS bulletin
David Sweigert
 
Content Marketing Ideas! How to Find the Best Stories to Tell Your Customers
Content Marketing Ideas! How to Find the Best Stories to Tell Your CustomersContent Marketing Ideas! How to Find the Best Stories to Tell Your Customers
Content Marketing Ideas! How to Find the Best Stories to Tell Your Customers
TopRank Marketing Agency
 
Python Programming: Type and Object
Python Programming: Type and ObjectPython Programming: Type and Object
Python Programming: Type and Object
Chan Shik Lim
 
Study notes for CompTIA Certified Advanced Security Practitioner (ver2)
Study notes for CompTIA Certified Advanced Security Practitioner  (ver2)Study notes for CompTIA Certified Advanced Security Practitioner  (ver2)
Study notes for CompTIA Certified Advanced Security Practitioner (ver2)
David Sweigert
 

Viewers also liked (16)

Python Programming: Tuning and Optimization
Python Programming: Tuning and OptimizationPython Programming: Tuning and Optimization
Python Programming: Tuning and Optimization
 
Python Programming: Data Structure
Python Programming: Data StructurePython Programming: Data Structure
Python Programming: Data Structure
 
Python Programming: Function
Python Programming: FunctionPython Programming: Function
Python Programming: Function
 
Python programming for Bioinformatics
Python programming for BioinformaticsPython programming for Bioinformatics
Python programming for Bioinformatics
 
H3 2011 모바일에서의 Location API 완전정복
H3 2011 모바일에서의 Location API 완전정복H3 2011 모바일에서의 Location API 완전정복
H3 2011 모바일에서의 Location API 완전정복
 
Cybercrime in Russia: Trends and Issues
Cybercrime in Russia: Trends and IssuesCybercrime in Russia: Trends and Issues
Cybercrime in Russia: Trends and Issues
 
『고성능 파이썬』 - 맛보기
『고성능 파이썬』 - 맛보기『고성능 파이썬』 - 맛보기
『고성능 파이썬』 - 맛보기
 
Understanding the black hat hacker eco system
Understanding the black hat hacker eco systemUnderstanding the black hat hacker eco system
Understanding the black hat hacker eco system
 
H3 2011 파이썬으로 클라우드 하고 싶어요
H3 2011 파이썬으로 클라우드 하고 싶어요H3 2011 파이썬으로 클라우드 하고 싶어요
H3 2011 파이썬으로 클라우드 하고 싶어요
 
Pycon2016 파이썬으로똑똑한주식투자 김대현
Pycon2016 파이썬으로똑똑한주식투자 김대현Pycon2016 파이썬으로똑똑한주식투자 김대현
Pycon2016 파이썬으로똑똑한주식투자 김대현
 
Object-oriented Programming in Python
Object-oriented Programming in PythonObject-oriented Programming in Python
Object-oriented Programming in Python
 
금융 데이터 이해와 분석 PyCon 2014
금융 데이터 이해와 분석 PyCon 2014금융 데이터 이해와 분석 PyCon 2014
금융 데이터 이해와 분석 PyCon 2014
 
Risks to Cloud based critical infrastructure -- DHS bulletin
Risks to Cloud based critical infrastructure -- DHS bulletinRisks to Cloud based critical infrastructure -- DHS bulletin
Risks to Cloud based critical infrastructure -- DHS bulletin
 
Content Marketing Ideas! How to Find the Best Stories to Tell Your Customers
Content Marketing Ideas! How to Find the Best Stories to Tell Your CustomersContent Marketing Ideas! How to Find the Best Stories to Tell Your Customers
Content Marketing Ideas! How to Find the Best Stories to Tell Your Customers
 
Python Programming: Type and Object
Python Programming: Type and ObjectPython Programming: Type and Object
Python Programming: Type and Object
 
Study notes for CompTIA Certified Advanced Security Practitioner (ver2)
Study notes for CompTIA Certified Advanced Security Practitioner  (ver2)Study notes for CompTIA Certified Advanced Security Practitioner  (ver2)
Study notes for CompTIA Certified Advanced Security Practitioner (ver2)
 

Similar to Python Programming: Class and Object Oriented Programming

2nd. aop
2nd. aop2nd. aop
2nd. aop
혜승 이
 
5장 객체와클래스
5장 객체와클래스5장 객체와클래스
5장 객체와클래스
SeoYeong
 
JPA Study - 1주차(SLIPP)
JPA Study - 1주차(SLIPP)JPA Study - 1주차(SLIPP)
JPA Study - 1주차(SLIPP)
Jeong-gyu Kim
 
Java(2/4)
Java(2/4)Java(2/4)
Java(2/4)
handfoot
 
Java mentoring of samsung scsc 2
Java mentoring of samsung scsc   2Java mentoring of samsung scsc   2
Java mentoring of samsung scsc 2
도현 김
 
The c++ programming language 10장 클래스 발표
The c++ programming language 10장 클래스 발표The c++ programming language 10장 클래스 발표
The c++ programming language 10장 클래스 발표재정 이
 
Swift3 subscript inheritance initialization
Swift3 subscript inheritance initializationSwift3 subscript inheritance initialization
Swift3 subscript inheritance initialization
Eunjoo Im
 
2015 Kitel C 언어 강좌3
2015 Kitel C 언어 강좌32015 Kitel C 언어 강좌3
2015 Kitel C 언어 강좌3
ssuseraf62e91
 
Java Annotation과 MyBatis로 나만의 ORM Framework을 만들어보자
Java Annotation과 MyBatis로 나만의 ORM Framework을 만들어보자Java Annotation과 MyBatis로 나만의 ORM Framework을 만들어보자
Java Annotation과 MyBatis로 나만의 ORM Framework을 만들어보자
Donghyeok Kang
 
파이썬 스터디 2주차
파이썬 스터디 2주차파이썬 스터디 2주차
파이썬 스터디 2주차
Han Sung Kim
 
SpringCamp 2013 : About Jdk8
SpringCamp 2013 : About Jdk8SpringCamp 2013 : About Jdk8
SpringCamp 2013 : About Jdk8Sangmin Lee
 
Xe hack
Xe hackXe hack
Xe hack
sejin7940
 
읽기 좋은 코드가 좋은 코드다 Part one
읽기 좋은 코드가 좋은 코드다   Part one읽기 좋은 코드가 좋은 코드다   Part one
읽기 좋은 코드가 좋은 코드다 Part oneJi Hun Kim
 
포트폴리오에서 사용한 모던 C++
포트폴리오에서 사용한 모던 C++포트폴리오에서 사용한 모던 C++
포트폴리오에서 사용한 모던 C++
KWANGIL KIM
 
일단 시작하는 코틀린
일단 시작하는 코틀린일단 시작하는 코틀린
일단 시작하는 코틀린
Park JoongSoo
 
Boost pp 20091102_서진택
Boost pp 20091102_서진택Boost pp 20091102_서진택
Boost pp 20091102_서진택
JinTaek Seo
 
Android Programming
Android ProgrammingAndroid Programming
Android Programming
Jake Yoon
 

Similar to Python Programming: Class and Object Oriented Programming (20)

2nd. aop
2nd. aop2nd. aop
2nd. aop
 
5장 객체와클래스
5장 객체와클래스5장 객체와클래스
5장 객체와클래스
 
JPA Study - 1주차(SLIPP)
JPA Study - 1주차(SLIPP)JPA Study - 1주차(SLIPP)
JPA Study - 1주차(SLIPP)
 
강의자료 2
강의자료 2강의자료 2
강의자료 2
 
Java(2/4)
Java(2/4)Java(2/4)
Java(2/4)
 
Java mentoring of samsung scsc 2
Java mentoring of samsung scsc   2Java mentoring of samsung scsc   2
Java mentoring of samsung scsc 2
 
강의자료3
강의자료3강의자료3
강의자료3
 
The c++ programming language 10장 클래스 발표
The c++ programming language 10장 클래스 발표The c++ programming language 10장 클래스 발표
The c++ programming language 10장 클래스 발표
 
Swift3 subscript inheritance initialization
Swift3 subscript inheritance initializationSwift3 subscript inheritance initialization
Swift3 subscript inheritance initialization
 
2015 Kitel C 언어 강좌3
2015 Kitel C 언어 강좌32015 Kitel C 언어 강좌3
2015 Kitel C 언어 강좌3
 
Java Annotation과 MyBatis로 나만의 ORM Framework을 만들어보자
Java Annotation과 MyBatis로 나만의 ORM Framework을 만들어보자Java Annotation과 MyBatis로 나만의 ORM Framework을 만들어보자
Java Annotation과 MyBatis로 나만의 ORM Framework을 만들어보자
 
파이썬 스터디 2주차
파이썬 스터디 2주차파이썬 스터디 2주차
파이썬 스터디 2주차
 
SpringCamp 2013 : About Jdk8
SpringCamp 2013 : About Jdk8SpringCamp 2013 : About Jdk8
SpringCamp 2013 : About Jdk8
 
Xe hack
Xe hackXe hack
Xe hack
 
읽기 좋은 코드가 좋은 코드다 Part one
읽기 좋은 코드가 좋은 코드다   Part one읽기 좋은 코드가 좋은 코드다   Part one
읽기 좋은 코드가 좋은 코드다 Part one
 
포트폴리오에서 사용한 모던 C++
포트폴리오에서 사용한 모던 C++포트폴리오에서 사용한 모던 C++
포트폴리오에서 사용한 모던 C++
 
일단 시작하는 코틀린
일단 시작하는 코틀린일단 시작하는 코틀린
일단 시작하는 코틀린
 
8.다중메서드
8.다중메서드8.다중메서드
8.다중메서드
 
Boost pp 20091102_서진택
Boost pp 20091102_서진택Boost pp 20091102_서진택
Boost pp 20091102_서진택
 
Android Programming
Android ProgrammingAndroid Programming
Android Programming
 

More from Chan Shik Lim

FPV Streaming Server with ffmpeg
FPV Streaming Server with ffmpegFPV Streaming Server with ffmpeg
FPV Streaming Server with ffmpeg
Chan Shik Lim
 
Improving monitoring systems Interoperability with OpenMetrics
Improving monitoring systems Interoperability with OpenMetricsImproving monitoring systems Interoperability with OpenMetrics
Improving monitoring systems Interoperability with OpenMetrics
Chan Shik Lim
 
pgday.seoul 2019: TimescaleDB
pgday.seoul 2019: TimescaleDBpgday.seoul 2019: TimescaleDB
pgday.seoul 2019: TimescaleDB
Chan Shik Lim
 
Kubernetes on Premise Practical Guide
Kubernetes on Premise Practical GuideKubernetes on Premise Practical Guide
Kubernetes on Premise Practical Guide
Chan Shik Lim
 
Kubernetes on Premise
Kubernetes on PremiseKubernetes on Premise
Kubernetes on Premise
Chan Shik Lim
 
Hadoop High Availability Summary
Hadoop High Availability SummaryHadoop High Availability Summary
Hadoop High Availability Summary
Chan Shik Lim
 

More from Chan Shik Lim (6)

FPV Streaming Server with ffmpeg
FPV Streaming Server with ffmpegFPV Streaming Server with ffmpeg
FPV Streaming Server with ffmpeg
 
Improving monitoring systems Interoperability with OpenMetrics
Improving monitoring systems Interoperability with OpenMetricsImproving monitoring systems Interoperability with OpenMetrics
Improving monitoring systems Interoperability with OpenMetrics
 
pgday.seoul 2019: TimescaleDB
pgday.seoul 2019: TimescaleDBpgday.seoul 2019: TimescaleDB
pgday.seoul 2019: TimescaleDB
 
Kubernetes on Premise Practical Guide
Kubernetes on Premise Practical GuideKubernetes on Premise Practical Guide
Kubernetes on Premise Practical Guide
 
Kubernetes on Premise
Kubernetes on PremiseKubernetes on Premise
Kubernetes on Premise
 
Hadoop High Availability Summary
Hadoop High Availability SummaryHadoop High Availability Summary
Hadoop High Availability Summary
 

Python Programming: Class and Object Oriented Programming