開発環境
- 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 1.を解いてみる。
その他参考書籍
- Pythonチュートリアル 第2版
- Python クックブック 第2版 (原書(最新版))
- Programming Python
- Python Pocket Reference (Pocket Reference (O'Reilly))
Test Your Knowledge: Quiz 1.
コード(BBEdit)
sample1.py
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
# 簡単な説明、コメントはhash-markで
# 詳しい説明や、__doc__で表示したいコメントはdocumentationstringsで記述
"""
これはpart3、chapter15の問題1のサンプルコードです
"""
def f():
"""
これはpart3、chapter15の問題1の関数fです
Hello, Documentationstrings!と標準出力に出力します
"""
print('Hello, Documentation strings!');
if __name__ == '__main__':
f()
入出力結果(Terminal, IPython)
$ ./sample1.py
Hello, Documentation strings!
$ ipython
Python 3.4.1 (default, Sep 20 2014, 19:44:17)
Type "copyright", "credits" or "license" for more information.
IPython 2.2.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import sample1
In [2]: print(sample1.__doc__)
これはpart3、chapter15の問題1のサンプルコードです
In [3]: print(sample1.f.__doc__)
これはpart3、chapter15の問題1の関数fです
Hello, Documentation strings!と標準出力に出力します
In [4]: quit()
$
0 コメント:
コメントを投稿