I stumbled into an interesting phenomenon with Python (3.7.6). I'd like to preface by saying that naming variables like this is a terrible idea that one should never do. However, the following code amazingly compiles:
list = (123, "abc", 222, "foo", "bar", 333); #Tuple named list
print(list);
However:
list = (123, "abc", 222, "foo", "bar", 333);
list = list(list);
print(list);
Raises a type error as tuples are not callable, and presumably it believes you are trying to call the tuple instead of cast the tuple to a list.
Of course, by changing the variable name like follows:
a = (123, "abc", 222, "foo", "bar", 333);
a = list(a);
print(a);
One is able to successfully cast a tuple to a list. It appears that this behavior exists for several different keywords. However, for some keywords this behavior is not seen such as with from. Can anyone explain this madness? Specfically, what keywords can be used as variables like this, and why is this even permitted in the first place?