Is there any analog of perl's pack()/unpack() in Python?

Alexander Semenov sav at
Mon Dec 25 03:47:51 EST 2000


Is there any way to read/write file with binary coded numbers in it?
I'm just tring to port this perl functions:
sub getlong {
        sysread FIL, $t, 4;
        return unpack('l',$t);

sub getfloat {
        sysread FIL, $t, 8;
        return unpack('d',$t)


I know, it's platform-dependent, but python has platform-dependent
modules and IEEE format is rather common.

Any suggestions?

Excuse me for my English, my native is Russian.

Thanks, Best Regards,
Alexander Semenov <sav at>

More information about the Python-list mailing list