twitterのほうでbotを動かしたりしてるのだけど、それの作成にあたってのメモ。 簡単なコマンドラインクライアントも兼ねていて、まあそれなりに使えるようになってる。 こんな感じでリストを表示してみたり。 色つきのprint エスケープ文字で囲んで色を指定する。 >>> print '\033[1;31mhoge\033[1;m' hoge 対話シェルの開始 いろいろ操作するための対話シェルモード。 開始はこんなコード。開始時にglobalsを渡しているのでimportせずに関数を呼び出せている。 def shell(handler): """対話シェル """ import code import rlcompleter import readline variables = globals() variables.update({'handler': handler}) print(
![twitter bot/クライアント作成のメモ - 偏った言語信者の垂れ流し](https://cdn-ak-scissors.b.st-hatena.com/image/square/3021ba0f79358811a10705dc24c1c963b655291d/height=288;version=1;width=512/http%3A%2F%2Fcdn-ak.f.st-hatena.com%2Fimages%2Ffotolife%2Fn%2Fnullpobug%2F20120716%2F20120716140521.png)