Refactor python code into a separate file.