Interpreter ignores type() command

Hi All,

Just a green beginner.

*** Python 3.9.10 (tags/v3.9.10:f2f3f53, Jan 17 2022, 15:14:21) [MSC v.1929 64 bit (AMD64)] on win32. ***
*** Remote Python engine is active ***

import numpy as np

When run, the print command executes, but the type function command is silent. I tried with PyScripter and a dozen online interpreters, all ignored the type() command except one, Colab. Wonder if I can get a comment?


Hi @whiffee. First of all, welcome to Python!

Have you tried print(type(x))? Let me explain you what’s happening.

On the Python REPL (called via python, without running files), and some other interpreters, whenever a function returns something (in this case the type of x), it will commonly print it:

>>>def foo():
...    return "Some stuff"
'Some stuff'

But in other interpreters, or when python runs a file, this won’t happen:

$ cat
def foo():
    return "Some stuff"

$ python

In this case, if you only want to show something, use print():

$ cat
def foo():
    return "Some stuff"

$ python
Some stuff

This should work for you.