Reputation: 566
I wrote a program of two lines in python. At first I tested it in the python shell. Here it is:
>>>state=True
>>>type(state)
<class 'bool'>
The output was as I expected in the shell. And then I wrote these instructions in a file named main.py.
#---------------main.py----------------#
state=True
type(state)
Then I executed this program using linux terminal as root user. The output was nothing
[manjaro ~]# python main.py
[manjaro ~]#
I expected that the output would be as it was in the shell. As a beginner In python I don't know why there was no output. Please help me to understand why there was no output.
Upvotes: 1
Views: 1588
Reputation: 107287
What you see is the raw representation of the object which is returned by __repr__
method of the respective object. It's what is called when you type an object in Python's interactive shell. When you're in a file you need to print the result using print
function that triggers the __str__
method.
state=True
print(type(state))
Upvotes: 4