I have a variable that holds the contents of a file I'd like to write in Jupyter using %%writefile
. However, only the cell magic line accepts variables, e.g. %%writefile $FILE_NAME
. Is there a way to make the contents dynamic, too, i.e. something like this?
%%writefile some.file
${variable_that_holds_contents_of_file}
The cell magic %save some.file variable
does it in a similar way, but it always creates a .py
file and that's not what I want in my use case. It's a JSON file.