MyEnigma

とある自律移動システムエンジニアのブログです。#Robotics #Programing #C++ #Python #MATLAB #Vim #Mathematics #Book #Movie #Traveling #Mac #iPhone

Pythonのseeモジュールをインストールする.

Pythonにはオブジェクトの関数とかを探すのに

dir()関数があります.

しかし,以前から思っていたのですが,

この結果が非常に見にくい...

>>>f={}
f={}
>>>dir(d)
['__class__', '__cmp__', '__contains__', '__delattr__', '__delitem__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__str__', 'clear', 'copy', 'fromkeys', 'get', 'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']


そこでいろいろ調べてみたら,

seeモジュールという,

オブジェクトの属性を簡単に,かつ見やすく表示する

モジュールを発見したのでインストールしてみました.




基本的には以下のブログの記事を参考にさせてもらいます.

easy_installが激しく便利 - テックノート@ama-ch

Coffee and Ashtray: pythonにsee()を入れる



まず初めに,see()モジュールをインストールするために,

easy_installというモジュールをインストールすることにします.

これは,MacにおいてPythonのモジュールを一瞬で

インストールするためのモジュールらしく,

easy_installをインストールした後では,

easy_install モジュール名

で多くの有名モジュールをインストールすることができるようになるらしいです.

すばらしいですね.



では,easy_installをインストールために,

以下のコマンドをターミナルに打ち込みます.

curl -O http://peak.telecommunity.com/dist/ez_setup.py


以上で,インストール終了です.

easy_installはその名のとおり,installもeasyです(笑).



あとは,see()モジュールをインストールするだけです.

以下のコマンドをターミナルに入力します.

easy_install see

以上です.

簡単簡単



最後にsee()の結果を見てみましょう.

>>> see(1)
+ - * / // % **
<< >> & ^ | +obj
-obj ~ < <= == != >
>= abs() bool() divmod() float() hash()
help() hex() int() long() oct() repr()
str() .conjugate() .denominator .imag
.numerator .real
>>>

美しい.....(TдT)