pickle fun
Pyenos
pyenos at pyenos.org
Wed Dec 20 21:21:28 EST 2006
class pickle_service:
import cPickle as p
# accept list as arg then serialize it to a file
def serialize(some_list,picklefile):
f=file(picklefile,"w")
p.dump(some_list,f) # so dumped this shit to the file
f.close()
# which one is the pickle? the file? no. just need the string of the name of file.
# unserialize what? picklefile of course ;)
def unserialize(some_pickle):
f= file(some_pickle) # wtf is going on here: open file for unpickling
return p.load(f) # unpickled: store it somewhere
class testpickleservice:
import pickle_service as p
p.serialize(["f","u","c","k"," ",["you"]],"testpickle")
print p.unserialize("testpickle")
AHAHAHAHA. funny.
More information about the Python-list
mailing list