Reading from a file
Kashyap Ashwin
Ashwin.Kashyap at thomson.net
Wed Aug 27 21:40:56 CEST 2008
Hello,
I am a total newbie to GMP, and I am trying to treat a big file as an
integer. How do I do this? I read the Python manual for gmpy and
understand I need to use mpz, but how do I load in the file? The file is
not in ASCII, it is an arbitrary binary file (like a .tgz or .zip).
This is the Python code that I have:
import gmpy
f1 = open("file1.zip").read()
f2 = open("file2.zip").read()
z1 = gmpy.mpz(f1) ## Fails as it expects a string like "4234234"
Any idea how I can accomplish this?
Thanks!
Ashwin
More information about the gmp-discuss
mailing list