Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
1 view
in Python by (47.6k points)

I am trying to run a speech to text script and here is a part of that code where I am getting an error:

import sys

import argparse

parser = argparse.ArgumentParser()

parser.add_argument('-f', dest=file, type=string)

args = parser.parse_args()

print args.file

But I am getting the following error:

NameError: name 'file_name' is not defined

1 Answer

0 votes
by (106k points)
edited by

You can solve this issue and the right data type for a destination in argpasrse module is a string. So, to solve the issue you need to pass a string in the arguments.

Below is the code for the same:-

parser.add_argument('-f', dest="file", type=string)

To know more about this you can have a look at the following video:-

Related questions

+2 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Nov 28, 2020 in Python by ashely (50.2k points)

Browse Categories

...