開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python 3.4 (プログラミング言語)
Learning Python (Mark Lutz (著)、Oreilly & Associates Inc)のPART Ⅱ.(Types and Operations)、Chapter 9.(Tuples, Files, and Everything Else)、Test Your Knowledge: Quiz 5.を解いてみる。
その他参考書籍
Test Your Knowledge: Quiz 5.
コード(BBEdit)
sample5.py
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
import copy
l = [1,2]
d1 = {'a':l, 'b':3}
d2 = d1
d3 = d1.copy()
d4 = copy.deepcopy(d1)
d1['b'] = 50
l[0] = 100
print(d1, d2, d3, d4, sep='\n')
入出力結果(Terminal, IPython)
$ ./sample5.py
{'b': 50, 'a': [100, 2]}
{'b': 50, 'a': [100, 2]}
{'b': 3, 'a': [100, 2]}
{'b': 3, 'a': [1, 2]}
$
0 コメント:
コメントを投稿