PyZipFile

John Machin machin_john_888 at hotmail.com
Fri Jul 13 07:37:29 EDT 2001


alankarmisra at hotmail.com (gods1child) wrote in message news:<25b2e0d9.0107122104.50347e10 at posting.google.com>...
> Why wont the following code work? Thanx.
> 
> import zipfile
> p = zipfile.PyZipFile("c:\\pe\\arc.zip","w",zipfile.ZIP_STORED)
> p.writepy("c:\\pe")
> p.close()
> p = zipfile.PyZipFile("c:\\pe\\arc.zip","r",zipfile.ZIP_STORED)
> eval(p.read("pe/lang.pyc"))
> p.close()
> 
> ----------------------------------------------------
> Traceback (most recent call last):
>   File "C:/pe/nest.py", line 6, in ?
>     eval(p.read("pe/lang.pyc"))
> TypeError: expected string without null bytes

eval() expects as its first argument either (a) a string of Python
*source* to be parsed and and evaluated or (b) a code object. You fed
it a string containing a whole pyc file, which is neither of those.

Perhaps you had better define "work". What did you expect it to do?



More information about the Python-list mailing list