is (like literally everything else in Python besides keywords) an object. Meaning it is an instance of a class (or type if you will). None is an instance of None, which you can find out, if you do this:NoneType
print(type(None))
So yes, has its own data type in Python.None
The class is special in the sense that it only ever has one instance: . And yes, there is a string representation defined for the None class. And the string representation is, well NoneType, which you see, when you do this: (all equivalent in this case)"None"
print(None)
print(str(None))
print(repr(None))
PS:
It is also worth stressing that is in fact a singleton. Meaning there only ever is exactly that one instance of the None class. This is why you can do identity comparisons with NoneType, i.e.:None
if my_variable is None:
...
As opposed to equality comparisons (which of course work too) like this:
if my_variable == None:
...
And when any function (including built-ins like ) have no explicit return statement or an empty one (like print without anything after it), they implicitly always return that one special return object.None
is a special-case singleton provided by Python. None is the type of the singleton object. NoneType is type(i) is None, but False should be true.type(i) is type(None)
You are not returning anything. Always use the statement to return a value from a function. Python does not use the last statement in a function as a return value.return
def getData(i, value):
global dataList
if condition:
return list(suffixList)
#do something
return getData(i, value)
A function that exits without an explicit , returns return instead.None