file handling class this involves changing only handful of lines solution is provided in bikestock_ans py debugging binary formats can be difficultbut tool that can help is one that can do hex dump of binary file' contents create program that has the following console help textusagexdump py [optionsfile [file filen]options- --help show this help message and exit - blocksize--blocksize=blocksize block size ( [default - --decimal decimal block numbers [defaulthexadecimal- encoding--encoding=encoding encoding (ascii utf- [defaultutf- using this programif we have binaryrecordfile that is storing records with the structure "< (little-endian -byte signed integer -byte byte string)by setting the block size to match one record ( bytes including the state byte)we can get clear picture of what' in the file for examplexdump py - test dat block bytes utf- characters alpha bravo charlie delta each byte is represented by two-digit hexadecimal numberthe spacing between each set of four bytes ( between each group of eight hexadecimal digitsis purely to improve readability here we can see that the second record ("bravo"has been deleted since its state byte is rather than the used to indicate nonblank nondeleted records use the optparse module to handle the command-line options (by specifying an option' "typeyou can get optparse to handle the string-to-integer conversion for the block size it can be quite tricky to get the headings to line up correctly for any given block size and to line up the characters correctly for the last blockso make sure you test with various block sizes ( alsodon' forget that in variable length filesthe last block may be short as the example illustratesuse periods to stand for nonprintable characters the program can be written in fewer than lines spread over two functions solution is given in xdump py