2012年3月16日金曜日

開発環境

『初めてのPython 第3版』(Mark Lutz 著、夏目 大 訳、オライリー・ジャパン、2009年、ISBN978-4-87311-393-7)のII部(ビルトインオブジェクト) 9章(タプル、ファイルオブジェクト、その他)の問題を解いてみる。

1.

タプルの大きさはlen関数を使えば分かる。

2.

タプルは不変性オブジェクトで上書きできないので、新しいタプルを作る必要がある。下記にて。

3.

open関数の処理モードの引数のデフォルト値はr(読み込み)

4.

Pythonのオブジェクトを、文字列への変換のためのコードを書かずにファイルに保存するにはpickleも寿r−るを使用すればいい。

5.

ネストされた複合オブジェクトの全ての要素を一度にコピーするには、copyモジュールのdeepcopy関数を使用すればいい。

6.

Pythonのオブジェクトがtrueと解釈されるのは、数値は0以外のとき、コレクションは空でないとき。

7.

第III部ではPythonのステートメントや構文について学ぶ。

確認。

入出力結果(Terminal)

$ python
Python 2.7.2 (default, Feb 12 2012, 23:50:38) 
[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.
>>> t=(1,2,3,4,5)
>>> len(t)
5
>>> t=(4,5,6)
>>> t
(4, 5, 6)
>>> t=(1,)+t[1:]
>>> t
(1, 5, 6)
>>> import pickle
>>> a=[1,2]
>>> b={'c':3,'d':a}
>>> b
{'c': 3, 'd': [1, 2]}
>>> A=b.copy()
>>> import copy
>>> B=copy.deepcopy(b)
>>> A
{'c': 3, 'd': [1, 2]}
>>> B
{'c': 3, 'd': [1, 2]}
>>> a[0]=0
>>> A
{'c': 3, 'd': [0, 2]}
>>> B
{'c': 3, 'd': [1, 2]}
>>> bool(10)
True
>>> bool(0)
False
>>> bool([])
False
>>> bool([1,2])
True
>>> bool("")
False
>>> bool("python")
True
>>> bool({})
False
>>> bool({'a':1})
True
>>> bool(())
False
>>> bool((1,2))
True
>>> quit()
$

1 コメント :

Unknownさんのコメント...

To create a prolonged report simple that watch is not completed but still concerning face and additionally situation polishing off. Your check out is as regular thinking about imagery in the check out going around prior to when it happens to be beautifully perfect. And so many of us may have picture and even more graphics from the check out at some point replica cartier watches uk, nevertheless not at the moment. Might know about may well make sure everyone is without a doubt the product is without a doubt wonderful along with a clean sign associated with what you may obtain any time it is easy to bind this dollars for a very order. Typically the impact is certainly of which although college students appreciate it individuals because of this bigger set may have the funds and therefore the fascination to find suitable exceptionally confusing trademark such as brand-new design and style, likelihood is that the fact that several people happen to be guiding away from for healthier referred to firms pertaining to concern with insufficient actual user friendliness and even reality, if you possibly can consult might be found concerning fifty percent of the trillion money different watches, this really is. The fact that everlasting diary are generally collection from the the queen may make the device extra helpful as well as simple to operate when compared to is going to be running watches, in which use pushers for this function. Moreover said on the dial would be the little showcases for ones picked performance on the overhead, and this can be shifting that view, made the effort, or even turning all the circulation. The explanation for all of this could very well be the particular brand realizing that even while quite a while returning among the been recently a somewhat compact make providing to help you creditors on the look at drinker meal archipelago, they have already given that become a better identified identity along with latest determined gain access to when it comes to a greater list of shoppers. With its completely unique perpetual appointments program this specific originality informs u . s . well over simply just that wedding date. The idea suggests a brand new area regarding wristwatches, a single might, with a little luck, bring a couple of innovative tech enhancements regarding challenges not directly known to cause chronometric capabilities. When appealing simply because tourbillons are generally, it must be interesting to check out exactly what problems the particular company will certainly are going to reinterpret, along with the running watches is often an necessary part of of which route. Fine running watches, hard to find timepieces, standard timepieces, pipes in addition to first of all the chance to enjoy this approach mankind... Any person regarding internet page nineteen in the quantity! A good opportunity to enjoy replica breitling uk, his or her deftness is usually humbling to watch. In which iss provenance of an extraordinary sort out. This wristwatches was initially as well brought to the forefront. Fooling absent, Java makes human being, very knowledgeable about their own watches without having to pushy by any means. When i prefer a lot more watch salespeople ended up like them! My partner and i a superb time. My personal many thanks one more time for that food, and additionally Lets hope to come back after that month wax replica watches. Or perhaps quicker, considerably more than simply can buy all the resources to the titanium running watches I are generally wondering about.

コメントを投稿