For achieving your result, you need to use the write() for storing the data in a python module:
file = open('Failed.py', 'w')
file.write('whatever')
file.close()
Here is a more pythonic version, which closes the file without any external commands, even if there was an exception in the wrapped block:
with open('Failed.py', 'w') as file:
file.write('whatever')
Kick-start your career in Python with the perfect Python Online Course!