I read a part of a file:
size_to_read = 999999
with open(file_name, "r") as f:
  read_part = f.read(size_to_read)
How do I know the size of a data (read_part) that actually was read in case if a size of a file is less than size_to_read?
I read a part of a file:
size_to_read = 999999
with open(file_name, "r") as f:
  read_part = f.read(size_to_read)
How do I know the size of a data (read_part) that actually was read in case if a size of a file is less than size_to_read?
 
    
    Simply check the length of the string with the built in len function:
size_to_read = 999999  
with open(file_name, "r") as f:  
  read_part = f.read(size_to_read)  
  if(not len(read_part) == size_to_read):
    eol_reached_unexpectedly()
