title: Python Argparse: Raw string input
body: <p>Apologies if this has been asked before, I did search for it but all hits seemed to be about python raw strings in general rather than regarding argparse.</p>
  
  <p>Anyways, I have a code where the user feeds in a string and then this string is processed. However, I have a problem as I want my code to be able to differentiate between <code>\n</code> and <code>\\n</code> so that the user can control if they get a line break or <code>\n</code> appear in the output (respectively). </p>
  
  <p>This in itself is quite simple, and I can get the logic working to check the string, etc. However, argparse doesn't seem to keep the input string raw. So if I were to write: <code>Here is a list:\nItem 1</code> it gets parsed as <code>Here is a list:\\nItem 1</code>. As the exact same thing gets parsed if I were to replace <code>\n</code> with <code>\\n</code> in the input string, it becomes impossible to differentiate between the two.</p>
  
  <p>I could include a bodge (for example, I could make the user enter say <code>$\n</code> for <code>\n</code> to appear in the output, or just <code>\n</code> for a line break). But this is messy and complicates the usage of the code.</p>
  
  <p>Is there a way to ensure the string being parsed by argparse is raw? (I.e. if I enter <code>\n</code> it parses <code>\n</code> and not <code>\\n</code>)</p>
  
  <p>Again, sorry if this has been asked before, but I couldn't find an answer and after over an hour of trying to find an answer, I'm out of ideas (bar the bodge). Cheers in advance for any and all help.</p>
  
  <p>Example code (sorry if this doesn't work, not sure how best to do example code for argparse!):</p>
  
  <pre><code>import argparse
  
  parser = argparse.ArgumentParser( description = 'Test.' )
  parser.add_argument( 'text', action = 'store', type = str, help = 'The text to parse.' )
  
  args = parser.parse_args( )
  
  print( repr( args.text ) )
  </code></pre>