I want to assign long multi-line strings in Mathematica. Is there a way of delineating a block without having to escape each instance of '"' with '\"' and each line ending with '\'?

i.e. In other languages we can do this: ''' mu very long multi line string with "quotes" '''


If I understand correctly, the closest to Python's triple quotes is a TextCell. You can enter it as follows:

enter text

Here I opened an inline cell after typing the input a =. This is done by pressing Ctrl-9 (or going to the Insert menu, then to Typesetting... and Start Inline Cell).

In the light orange highlighted box, you can type any text you want in a natural way, just like in Python between """.

  • $\begingroup$ I hit a snag when trying to use the variable 'a' in your example above in a function that expects a string. In this case, I want to call result = REvaluate[a] But I get an error because REvaluate expects a string, not a TextCell. Any ideas? $\endgroup$ – drsquidop Aug 15 '15 at 5:41
  • $\begingroup$ I figured it out from one of your other posts. I used a = ToString@@ Ctrl-9 my text here Ctrl-0 $\endgroup$ – drsquidop Aug 15 '15 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.