title: How do I write a program that both accepts commandline arguments with argparse and accepts arguments to objects created from class?
body: <p>How do I write a program that both accepts commandline arguments with <code>argparse</code> and accepts arguments to <code>__init__</code> so the program can be used outside the commandline? I'm also wondering if I need to use <code>os.getcwd()</code> explicitly when exporting a file. Thanks so much for the help!</p>
  
  <pre><code>class MyClass(object):
       def __init__(self, file='', duplicate_column_name='', file_destination=''):
           self.__file1 = file
           self.__duplicate = duplicate_column_name
           self.__file_dest = file_destination
  
  
      if __name__ == __main__:
           parser = argparse.ArgumentParser(add_help=True, description="Allows users to filter CSV file in a variety of ways.")
           parser.add_argument('-f', action='store', dest = 'file', help='Store the name of the csv file you want converted')
           parser.add_argument('-c', action='store', dest = 'column', help='Store the name of the column you want filtered.')
           parser.add_argument('-d', action='store', dest = 'file_destination', default= str( os.getcwd() ) + "/filteredcsvfile.csv", help= "Store the name of the file you'd like the program to create")
  
           if len(sys.argv) &lt;= 2:
               parser.print_help()
               sys.exit(1)
  
           cmd_args = parser.parse_args()
           file = cmd_args.file
           duplicate_column_name = cmd_args.column
           file_destination = cmd_args.file_destination
  </code></pre>