Can anyone translate this piece of code into Pytho - C#