How can I get `sed`-like behavior from within python when running windows? : The beginnings of a solution are shown below. If someone would complete it and get it working, I would be eternally grateful.

    import subprocess
    import os
    import sys

    def sed(stryng, istream=None, ostream=None):
    
        if sys.platform == "linux":
            subprocess.run(["sed", stryng])        
            subprocess.call(['sed', 's/\"//g', inp], stdout=out_file)
        elif os.name == 'nt':
            # if running Windows
            lead_up = "@ powershell - Command get-content somefile.txt | %{{$_ -replace "
            expression = ""
            replacement = ""
            subprocess.run(lead_up + f"\"\"{expression}\",\"{replacement}\"}}")
        else:
            raise NotImplementedError()

Usage:

    in_file  = open("report_new.txt", "r")
    out_file = open("report_new.txt", "w")
    sed("'s/Nick/John/g'", in_file, out_file)
    out_file.close()
    in_file.close()