code: def run_edisgo_twice(run_args):
      
  
      # base case with no generator import
      edisgo_grid, \
      costs_before_geno_import, \
      grid_issues_before_geno_import = run_edisgo_basic(*run_args)
  
      if edisgo_grid:
          # clear the pypsa object and results from edisgo_grid
          edisgo_grid.network.results = Results(edisgo_grid.network)
          edisgo_grid.network.pypsa = None
  
          # case after generator import
          # run_args = [ding0_filename]
          # run_args.extend(run_args_opt)
          run_args.append(edisgo_grid)
  
          _, costs, \
          grid_issues = run_edisgo_basic(*run_args)
  
          return costs_before_geno_import, grid_issues_before_geno_import, \
                 costs, grid_issues
      else:
          return costs_before_geno_import, grid_issues_before_geno_import, \
                 costs_before_geno_import, grid_issues_before_geno_import
docs: Run grid analysis twice on same grid: once w/ and once w/o new generators
  
      First run without connection of new generators approves sufficient grid
      hosting capacity. Otherwise, grid is reinforced.
      Second run assessment grid extension needs in terms of RES integration
  
      Parameters
      ----------
      run_args : list
          Optional parameters for :func:`run_edisgo_basic`.
  
      Returns
      -------
      all_costs_before_geno_import : :pandas:`pandas.Dataframe<dataframe>`
          Grid extension cost before grid connection of new generators
      all_grid_issues_before_geno_import : dict
          Remaining overloading or over-voltage issues in grid
      all_costs : :pandas:`pandas.Dataframe<dataframe>`
          Grid extension cost due to grid connection of new generators
      all_grid_issues : dict
          Remaining overloading or over-voltage issues in grid