Re: [Tutor] extracting a cPickle/pickle file from inside a zip file

2014-08-29 Thread Danny Yoo
Hi Dillup, One other comment other than the zipfile stuff: you might want to consider something other than pickle format if you want interchangeability with other tools. JSON, for example, is pretty well-supported in the json library: https://docs.python.org/2/library/json.html and it has

Re: [Tutor] extracting a cPickle/pickle file from inside a zip file

2014-08-29 Thread Danny Yoo
> now if i do this > > outfile = cStringIO.StringIO() > outfile.write(pyfromzip) > z=cPickle.load(outfile) Do you have to rewind the outfile so that the read is properly positioned? The following interaction: # >>> import StringIO >>> out = StringIO.StringIO() >>> ou

Re: [Tutor] extracting a cPickle/pickle file from inside a zip file

2014-08-29 Thread diliup gabadamudalige
http://stackoverflow.com/questions/3006727/load-a-pickle-file-from-a-zipfile zf = czipfile.ZipFile(r"cpickletest.zip") pyfromzip = zf.read ("cPickletest.py", pwd="python") print pyfromzip, type(pyfromzip) this prints the following to the console (dp1 S'kola.jpg' p2 S'CSVTQq#w.@lm' p3 sS'p2.jpg'

Re: [Tutor] extracting a cPickle/pickle file from inside a zip file

2014-08-29 Thread Alan Gauld
On 29/08/14 10:00, diliup gabadamudalige wrote: pload = cPickle.load(zf.open("my.py",pwd=password)) this gives an EOF . Does any body know why? I've never used zipfile so I don't know, but could it be related to the fact that your pickle file is binary? Do you need any flags to tell zipfile t

[Tutor] extracting a cPickle/pickle file from inside a zip file

2014-08-29 Thread diliup gabadamudalige
HI! To all, with open(from_dir + "\\" + name_py,"wb") as outfile: cPickle.dump(str1,outfile) after doing above I zip the file with some other files into a password secured zip file using win rar. I can extract all other files except the py file. pload = cPickle.load(zf.open("my.py",pwd=passw