Closed aresper closed 11 months ago
@aresper Codon cannot type check sys.argv
, because it is an empty list.
You should use Codon's sys instead of Python's sys.
from python import sys as py_sys
import sys
def main(arg1: str, arg2: str) -> None:
input_arg_1 = arg1
input_arg_2 = arg2
print(input_arg_1, input_arg_2)
if __name__ == "__main__":
print(py_sys.argv)
print(sys.argv)
arg1 = sys.argv[1]
arg2 = sys.argv[2]
main(arg1, arg2)
Yes, please use Codon's sys.argv
: Python's sys.argv
won't work at all.
My script takes two command line arguments (numbers) and I am trying to process them as follows:
However, I am getting the following error: me@desktop:~/Python-sandbox/codon-tests$ codon build -exe main_0_0.py main_0_0.py:3253:5-9: error: cannot typecheck the program ╰─ main_0_0.py:3253:5-9: error: during the realization of main(arg1: str, arg2: str)
Can someone explain what is wrong with the type checking I am doing?