I try to call from C# a python script divided in many functions. With these parts of code output is empty.
import sys
def main():
    print('Hello')
    if len(sys.argv) >=3:
        x = sys.argv[1]
        y = sys.argv[2]
        # print concatenated parameters
        main2(x,y)
def main2(x,y):
    print(x+y)
if __name__=='__main__':
    main()
C#:
int x = 1;
int y = 2;
string progToRun = "main.py";
Process proc = new Process();
proc.StartInfo.FileName = @"C:\Program Files\Python37\python.exe";
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.Arguments = string.Concat(progToRun, " ", x.ToString(), " ", y.ToString());
proc.Start();
StreamReader sReader = proc.StandardOutput;
string output = sReader.ReadToEnd();
proc.WaitForExit();
Console.ReadLine();
With this python script it works:
import sys
def main():
    print('Hello')
    if len(sys.argv) >=3:
        x = sys.argv[1]
        y = sys.argv[2]
        # print concatenated parameters
        print(x+y)
if __name__=='__main__':
    main()
What's the difference between the two pyhton scripts? How can I use in C# a python script with many functions? Can I execute a python script wihtout sending parameters(x and y)?
Thank You.
 
    