new_contents: """Snipppets of potentially reusable code that don't deserve their
  own library."""
  
  import bisect
  
  class Location:
      def __init__(self, name, line, col):
          self.name = name
          self.line = line
          self.col = col
  
      def __str__(self):
          return "{}:{}.{}".format(self.name, self.line, self.col)
  
  
  class Locator:
      """Locator provides a way to convert an absolute offset in a
      string into a Location object.
  
      """
  
      def __init__(self, data, name='<string>'):
          self.name = name
          self.line_offsets = [0]
          for line_len in map(len, data.splitlines(True)):
              self.line_offsets.append(self.line_offsets[-1] + line_len)
  
      def locate(self, offset):
          """Return a Location() object for the given offset."""
          line = bisect.bisect_right(self.line_offsets, offset)
          col = offset - self.line_offsets[line - 1]
          return Location(self.name, line, col)
  
subject: Add Locator snippet