Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Convert to Integer in Python

Name: Anonymous 2008-06-10 14:03


def readBMP( filename):
    f = file( filename)
    content = f.read()
    f.close()
    return content
   
def getDimensions( bytes):
    return bytes[18:22],bytes[22:26]

w,h = getDimensions( getBMP( 'test.bmp'))


how do i convert w and h to int?
atm (w,h) == ('\x05\x00\x00\x00', '\x05\x00\x00\x00')

Name: Cudder !MhMRSATORI!FBeUS42x4uM+kgp 2012-05-26 8:07

>>23
Inefficient.

If by "not portable" you mean the size of the types, just use the appropriate size (C99 has some defined, I never bother to use them because I know what size my ints/shorts/longs are for the platform I'm developing on.)

Name: Anonymous 2012-05-26 8:23

>>23
this has to be the shittiest code I've seen in /prog/
and he goes all this way, without even taking care of endianity

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List