Is it possible to write the value of a variable in the magic of the %% writefile command in an IPython notebook?
I want to be able to use a variable to output some text in an IPython Notebook. I can write a file from IPython Notebook using %% writefile command. I can also use a variable to name the file using $ varaible_name.
file_name = "file.out"
some_variable = "text"
New cell
%%writefile $file_name
????some_varaible #<-what command goes here
So the output file (named "file.out") looks like this:
text
+3
source to share