If I have a file say a img, and I try to divide the file into 14xx byte chunks by reading 1 byte at a time through a generator and join them together in a variable, why is the resulting variable not 14xx byte? Is it because of the internal handling of the variable in python? If so what are some possible way to test if I actually have a 14xx data besides having my create_data function return another indicator?
def split_file(self, filename):
with open(filename, "rb") as f:
while True:
byte = f.read(1)
if not byte:
break
yield(byte)
def create_data(self):
for x in range (1, 1472):
next_byte = split_file.filename
if not next_byte :
break
else:
msg = msg + split_file(self.filename)
return msg
curr_data = self.create_data
while sys.getsizeof(curr_data) == 1472:
# do something with curr_data
Thanks in advance