Reputation: 3
I know about the built-in function type()
It works fine in the interactive mode of python. But when you try and use it in a .py file, nothing gets displayed.
Which method should I use if I want to check the data type inside a python script/file?
Upvotes: 0
Views: 1937
Reputation: 6068
It seems to me that the problem is not the type
function, but rather how you are generating output. In interactive mode, stuff that you type on the console generates output, but when scripting it does not. You need to explicitly tell it to output:
print(type(x))
Upvotes: 4