2005-02-01から1ヶ月間の記事一覧

[Python] pickle でCODEオブジェクトをシリアライズ (yat another way)

from new import * import pickle, marshal, struct CODE='C' # opcode(CODE)が重複していないか確認する if (not pickle.Pickler.dispatch.has_key(code) and not pickle.Unpickler.dispatch.has_key(CODE)): def save_code(self, obj): """保存用メソッド"…

[Ruby] pikeのような文字列操作の拡張

class String def -(c) delete c end def /(c) split c end end p "foo,bar,baz" / "," # => ["foo", "bar", "baz"] p "hoge\nhoge\n" - "\n" # => "hogehoge" TODO How to do it in Python ?

登録してみた. http://rubyforge.org/projects/rupy/ RuPy Marshal # marshal_dump.py ... データ作成の為のPython script import sys, marshal def main(filename="test.dump"): data = [ 10, 10.0, -10000, os.environ.get('USER',None), ['foo@example.or…