2005-01-01から1年間の記事一覧

[Python][Ruby] mini-pickle (solver for pythonchallenge level 5)

Few days, I was having fun with pythonchallenge.com as you do. I like the idea of the challanges, I think any programmers could enjoy it. but unfortunally. it requires some Python specific modules. fmm...there are hints which hard to notic…

[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…