I looked at this example and tried to write a class which holds the header information. From another class, I would call this class and get the dictionary to use.
# -*- coding: utf-8 -*-
import binascii
import codecs
from datetime import datetime
from collections import defaultdict
class HeaderInfo(dict, object):
    def __init__(self):
        header_dict = defaultdict(list) # This shall hold all the issues in the parsed file
        # super(HeaderInfo, self).__init__(file)
        self._object = "C:\Sample.log"
        file = open(self._object, "rb")
        self._dict = {}
        byte = file.read(4)
        logFileSize = int.from_bytes(byte, "little")
        header_dict = self.add('logFileSize', logFileSize)
        dict = self.add('logFileSize', logFileSize)
        # print((dict))
        byte = file.read(20)
        hexadecimal = binascii.hexlify(byte)
        header_dict = self.add('fileType', codecs.decode(hexadecimal, "hex").decode('ascii'))
        dict = self.add('fileType', codecs.decode(hexadecimal, "hex").decode('ascii'))
        # print((dict))
        byte = file.read(5)
        hexadecimal = binascii.hexlify(byte)
        header_dict = self.add('fileVersion', codecs.decode(hexadecimal, "hex").decode('ascii'))
        dict = self.add('fileVersion', codecs.decode(hexadecimal, "hex").decode('ascii'))
        # print((dict))
        byte = file.read(10)
        hexadecimal = binascii.hexlify(byte)
        header_dict = self.add('fileNumber', codecs.decode(hexadecimal, "hex").decode('ascii'))
        dict = self.add('fileNumber', codecs.decode(hexadecimal, "hex").decode('ascii'))
    def add(self, id, val):
        self._dict[id] = val
        return self._dict
# print the data    
hi = HeaderInfo()    
print(hi)
when I tried with print statements,the data is printed, but
hi = HeaderInfo()
, doesn't return anyvalue in "hi".
any idea to return the dict value if HeaderInfo() is called?
 
     
    