開発環境
- OS X Lion - Apple(OS)
- TextWrangler(Text Editor) (BBEditの無料機能制限版、light版)
- Script言語: Python
『初めてのPython 第3版』(Mark Lutz 著、夏目 大 訳、オライリー・ジャパン、2009年、ISBN978-4-87311-393-7) のV部(モジュールのインポート、リロード)の19章(モジュールのインポート、リロードとインポート)練習問題1を解いてみる。
1.
テキストエディタ等を使用して作成する。
コード(TextWrangler)
sample.py
#!/usr/bin/env python #encoding: utf-8 a = 10 b = "Python" def f(): print("Hello, Python!")
入出力結果(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 sample >>> sample.a 10 >>> sample.f <function f at 0x105c32050> >>> sample.f() Hello, Python! >>> sample.b 'Python' >>> print(sample.b) Python >>> quit() $
0 コメント:
コメントを投稿