開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Python (プログラミング言語)
Learning Python (Mark Lutz (著)、Oreilly & Associates Inc)のPART III.(Statements and Syntax)、CHAPTER 15(The Documentation Interlude)、Test Your Knowledge: Quiz 1, 2, 3, 4.を解いてみる。
その他参考書籍
Quiz 1, 2, 3, 4.
コード(BBEdit)
sample.py
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
'''
documentation strings確認用のモジュール
'''
def f():
'''
この関数の詳しい説明、その表示をしたい場合は#によるコメントではなく
documentation stringsを使う方がいい。
'''
print('Hello documentation strings world!')
入出力結果(Terminal)
$ python3 Python 3.3.4 (default, Feb 10 2014, 22:06:52) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import sample >>> sample.__doc__ '\ndocumentation strings確認用のモジュール\n' >>> sample.f.__doc__ '\n この関数の詳しい説明、その表示をしたい場合は#によるコメントではなく\n documentation stringsを使う方がいい。\n ' >>> help(sample) >>> dir(str) ['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'capitalize', 'casefold', 'center', 'count', 'encode', 'endswith', 'expandtabs', 'find', 'format', 'format_map', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'isidentifier', 'islower', 'isnumeric', 'isprintable', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'maketrans', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill'] >>> dir(sample) ['__builtins__', '__cached__', '__doc__', '__file__', '__initializing__', '__loader__', '__name__', '__package__', 'f'] >>> quit() $ python3 -m pydoc -b Server ready at http://localhost:56942/ Server commands: [b]rowser, [q]uit server> q Server stopped $
0 コメント:
コメントを投稿