title: Passing a tuple as command line argument
body: <p>My requirement is to pass a tuple as command line argument like </p>
  
  <pre><code>--data (1,2,3,4)
  </code></pre>
  
  <p>I tried to use the <code>argparse</code> module, but if I pass like this it is receiving as the string <code>'(1,2,3,4)'</code>. I tried by giving <code>type=tuple</code> for <code>argparse.add_argument</code>, but is of no use here.</p>
  
  <p>Do I have to add a new type class and pass that to type argument of <code>add_argument</code>?</p>
  
  <p><strong>Update</strong></p>
  
  <p>I tried the <code>ast.literal_eval</code> based on answers. Thanks for that. But it is giving spaces in the result as shown below.</p>
  
  <pre><code>(1,2,3,4)
  &lt;type 'str'&gt;
  (1, 2, 3, 4)
  &lt;type 'tuple'&gt;
  </code></pre>