開発環境
- 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 Ⅲ.(Statements and Syntax)、Chapter 15.(The Documentation Interlude)、Test Your Knowledge: Quiz 3.を解いてみる。
その他参考書籍
- Pythonチュートリアル 第2版
- Python クックブック 第2版 (原書(最新版))
- Programming Python
- Python Pocket Reference (Pocket Reference (O'Reilly))
Test Your Knowledge: Quiz 3.
コード(BBEdit)
sample3.py
#!/usr/bin/env python3 #-*- coding: utf-8 -*- # built-in functionのdirを使えばいい。 # 引数に渡すのは、名前でも、直接でもどちらでも可能。 # listのattributes(__で始まるattributesは除外) attributes1 = filter(lambda a: not a.startswith('__'), dir(list)) attributes2 = filter(lambda a: not a.startswith('__'), dir([])) list1 = list(attributes1) list2 = list(attributes2) print(list1) print(list2) print(list1 == list2)
入出力結果(Terminal, IPython)
$ ./sample3.py ['append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort'] ['append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort'] True $
0 コメント:
コメントを投稿