A Question of Identity

One of the things I really dislike about Python is that you never know what anything is. You see a variable states, and you wonder it this is a list, or a dictionary, or a numpy array, or a Pandas series or dataframe. Because they all have to be treated differently. This is especially a problem when trying to understand someone else’s code.

When I was teaching IT I was mostly teaching Java. You know what everything is, you have to declare the type when you declare the variable name. And you can’t change the type just by assigning something else to it. Python is a breeze to write and a nightmare to read, especially complex stuff.

One can implement type hinting in Python, and I think I might do that for all code that I’m trying to read. Just add types whereever I can and hope that the author doesn’t just change it on the fly. Perhaps I can also make use of datatypes such as the namedtuple. Anything to help identifying what something is so I know what I can do with it.