i\'ve the following code in perl from a friend, but i wanted to have in python as that\'s where all the framework will be, what could be equivalent python code, am still new