I am trying to figure out a type mismatch while adding a string to another string in a concatenate operation.
Basically the error returned is a TypeError
(cannot concatenate string and tuple); so I would like to figure out where I assigned a value as tuple instead of string.
All the values that I assign are strings, so I gotta figure out where the tuple is coming from, so I was hoping that there is a way in Python to find out what is contained inside a variable and what type is it.
So far using pdb I was able to check the content of the variables, and I get correctly the values that I would expect; but I would like to know also the type of the variable (by logic, if the compiler is able to raise a type error, it means that it knows what is inside a variable and if it is compatible with the operation to perform; so there must be a way to get that value/flag out).
Is there any way to print out the type of a variable in python?
BTW, I tried to change all my variables to be explicitly strings, but is not feasible to force str (myvar)
, so I cannot just cast as string type everywhere I use strings.