title: Confused about argparse
body: <p>I am having some trouble understanding how argparse works and I've combed through the documentation but am still having some difficulty understanding.</p>
  
  <pre><code>def arguments():
  parser = argparse.ArgumentParser(description='Test..')
  parser.add_argument("-i", "--input-file", required=True, help="input file name")
  parser.add_argument("-o", "--output-file", required=True, help="output file name")
  parser.add_argument("-r", "--row-limit", required=True, help="row limit to split", type=int)
  args = parser.parse_args()
  
  is_valid_file(parser, args.input_file)
  
  is_valid_csv(parser, args.input_file, args.row_limit)
  
  return args.input_file, args.output_file, args.row_limit
  
  def is_valid_file(parser, file_name):
  """Ensure that the input_file exists"""
  if not os.path.exists(file_name):
      parser.error("The file {} does not exist".format(file_name))
      sys.exit(1)
  
  def is_valid_csv(parser, file_name, row_limit):
  """
  Ensure that the # of rows in the input_file
  is greater than the row_limit.
  """
  row_count = 0
  for row in csv.reader(open(file_name)):
      row_count += 1
  if row_limit &gt; row_count:
      parser.error("More rows than actual rows in the file")
      sys.exit(1) 
  </code></pre>
  
  <p>The code above works fine, but once I remove "--row-limit" on line 5, I get a </p>
  
  <pre><code>Traceback (most recent call last):
   File ".\csv_split.py", line 95, in &lt;module&gt;
    arguments = arguments()
   File ".\csv_split.py", line 33, in arguments
    is_valid_csv(parser, args.input_file, args.row_limit)
  AttributeError: 'Namespace' object has no attribute 'row_limit'
  </code></pre>
  
  <p>Why does removing the "--row-limit" present me with this error?</p>