'print(args.task[0]) TypeError: 'NoneType' object is not subscriptable
def get_opts():
model_names = sorted(
name
for name in models.__dict__
if name.islower()
and not name.startswith("__")
and callable(models.__dict__[name])
)
# general setting
parser = argparse.ArgumentParser(description="ACPL")
parser.add_argument("--task", choices=["cx14", "cxp", "isic"], nargs="*", type=str)
args = parser.parse_args(args=[])
return args
args = get_opts()
print(args.task[0])
The following is the error message displayed:
TypeError Traceback (most recent call last)
<ipython-input-33-5fd1fb76e64f> in <module>()
1 args = get_opts()
----> 2 print(args.task[0])
TypeError: 'NoneType' object is not subscriptable
What did I do wrong? Why the type of "args.task" is "None"? Why not a "list"?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|