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

alankarmisra at (gods1child) wrote in message news:<25b2e0d9.0107122104.50347e10 at>...
> Why wont the following code work? Thanx.
> import zipfile
> p = zipfile.PyZipFile("c:\\pe\\","w",zipfile.ZIP_STORED)
> p.writepy("c:\\pe")
> p.close()
> p = zipfile.PyZipFile("c:\\pe\\","r",zipfile.ZIP_STORED)
> eval("pe/lang.pyc"))
> p.close()
> ----------------------------------------------------
> Traceback (most recent call last):
>   File "C:/pe/", line 6, in ?
>     eval("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