開発環境
- OS X Lion - Apple(OS)
- TextWrangler(Text Editor) (BBEditの無料機能制限版、light版)
- Script言語: Python
『初めてのPython 第3版』(Mark Lutz 著、夏目 大 訳、オライリー・ジャパン、2009年、ISBN978-4-87311-393-7) のIII部(ステートメント)14章(Pythonのドキュメント)を解いてみる。
1.
長めのコメントや、ソースファイルを開かなくても内容を表示できるようにしたい場合。
2.
- __doc__属性
- PyDocを使用
- help関数を使用
3.
dir関数を使用すればいい。
4.
PyDocで空白のまま検索すれば全てのモジュールのリストが表示される。
入出力結果(Terminal)
$ python Python 3.2.3 (default, Apr 18 2012, 20:17:30) [GCC 4.2.1 Compatible Apple Clang 3.0 (tags/Apple/clang-211.12)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import math >>> print(math.__doc__) This module is always available. It provides access to the mathematical functions defined by the C standard. >>> dir(math) ['__doc__', '__file__', '__name__', '__package__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'hypot', 'isfinite', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'trunc'] >>> quit() $
0 コメント:
コメントを投稿