code: def pickle_matpower_cases(case_paths, case_format=2):
      
      import pylon.io
  
      if isinstance(case_paths, basestring):
          case_paths = [case_paths]
  
      for case_path in case_paths:
          # Read the MATPOWER case file.
          case = pylon.io.MATPOWERReader(case_format).read(case_path)
  
          # Give the new file the same name, but with a different extension.
          dir_path = os.path.dirname(case_path)
          case_basename = os.path.basename(case_path)
          root, _ = os.path.splitext(case_basename)
          pickled_case_path = os.path.join(dir_path, root + '.pkl')
  
          # Pickle the resulting Pylon Case object.
          pylon.io.PickleWriter(case).write(pickled_case_path)
docs: Parses the MATPOWER case files at the given paths and pickles the
          resulting Case objects to the same directory.