Read binay file with readinto method

Hi

i am preparing tp pass PCAP exam, so in section PCAP – Python Certification Course | KodeKloud

whats the meaning of defining data twice :slight_smile:
to intialize with zero
to read binary file and assign this content in the same var data

Best regards
Mourad

Hi Mourad, Thanks for your query.

data = bytearray(10) //We are initialising data here
bf.readinto(data) // we are loading the content of open file to data list

in the for loop we are reading data list and printing the byte content in hex. We are not defining data twice here.

Hope this clarifies your query

Thanks
JSKY