## 2014年5月3日土曜日

### Python - Classes and OOP(Inheritance)

Learning Python (Mark Lutz (著)、Oreilly & Associates Inc)のPART Ⅵ.(Classes and OOP)、CHAPTER 32(Advanced Class Topics)、Test Your Knowledge: Part VI Exercises 1.(Inheritance)を解いてみる。

その他参考書籍

1.(Inheritance)

コード(BBEdit)

sample.py

```#!/usr/bin/env python3
#-*- coding: utf-8 -*-

print('Not implemented')

return x + y

res = {}
for k, v in x.items():
res[k] = v
for k, v in y.items():
res[k] = v
return res

def __init__(self, data):
self.data = data
print('Not implemented')
if isinstance(other, self.__class__):
other = other.data

return x + y

res = {}
for k, v in x.items():
res[k] = v
for k, v in y.items():
res[k] = v
return res

if __name__ == '__main__':

t = a + b
t = a + 10
print(c + d)
print(c + [3,4,5])
print(e + f)
print(e + {'c':3, 'd':4, 'e':5})

```

``` ./sample.py
Not implemented
[1, 2, 3, 4, 5]
{'b': 2, 'c': 3, 'd': 4, 'e': 5, 'a': 1}
Not implemented
Not implemented
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5]
{'b': 2, 'c': 3, 'd': 4, 'e': 5, 'a': 1}
{'b': 2, 'c': 3, 'd': 4, 'e': 5, 'a': 1}
\$
```