0

I saw this example on Redshift's python connector docs, I got confused

result: numpy.ndarray = cursor.fetch_numpy_array()

So I tried some commands and got more confused.

When I tried running the below code in the terminal there we no errors yet the variable was not defined with None (I assumed it should be)

name:str

Then I assumed it could be just indicate datatype so I tried below command and it generated no error.

name:dir

I am pretty confused. Can please anyone help me understand where I am being lost. Thanks in advance

  • `name:dir` does not give an error because `dir` exists as a builtin function. The `:dir` part is an annotation, it is not checked by the Python interpreter, so as long as the name `dir` is in scope you will not get an error. If you run a static type checker such as `mypy` on it you will get an error like: _"Function "builtins.dir" is not valid as a type"_ (you can try it out at https://mypy-play.net/) – Anentropic Aug 22 '23 at 10:05

0 Answers0