Reading from a file

Kashyap Ashwin Ashwin.Kashyap at
Wed Aug 27 21:40:56 CEST 2008

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("").read()
f2 = open("").read()

z1 = gmpy.mpz(f1)    ## Fails as it expects a string like "4234234"

Any idea how I can accomplish this?


More information about the gmp-discuss mailing list