I know that I can use the following magic functions in Jupyter to write the content of a cell to a given file:
%%writefile ./file.txt
I wrote my own magic functions based on this writefile function. The question is how can I use it but in .py file, not jupyter notebook? Because in .py we don't have cells.