I am calling a Python (3.8) script from Terminal on Mac using zsh (5.8) leading to the error message in the title. I found a workaround for this problem (albeit not elegant), but I would like to understand what is going wrong.
My Python file test.py:
import argparse
from ast import literal_eval
parser = argparse.ArgumentParser(description="test")
parser.add_argument("--test", default="", type=str, help="test")
args = parser.parse_args()
print(literal_eval(args.test))
Calling this script from command line using python test.py --test (0.4,0.3) results in this error message zsh: unknown file attribute: 0
What does that mean?
Explanation about literal_eval:
literal_eval takes a string like "(0.3,0.4)" and evaluates it as tuple s.t.
a = literal_eval("(0.3,0.4)")
type(a)
<class 'tuple'>