Ami Winter
Ami Winter

Reputation: 51

What is the meaning of the type "NONE" (like int,bool,string...)

I have seen the type NONE in a book but with no explanation... I understood that this is a type in some languages but I wish to understand it in depth! Is it like void? or like NULL?

The book called "Programming language concepts and paradigms" (writen by David A.Watt) and it has a very good "wide view" of many languages and the differences between one another. In what languages do we use NONE (except Python)? Is where more than one purpose for the nonetype?

Thanks! Amihay

Upvotes: 0

Views: 209

Answers (2)

boreing
boreing

Reputation: 1

IMO, the NoneType in python is quite equivalent to a void-type in other languages, such as C/C++. Example:

>>> def foo():
...     pass
... 
>>> type(foo())
<type 'NoneType'>

The function foo() has no return statement, so it's like a void-returning function in C/C++.

Upvotes: 0

Mark Byers
Mark Byers

Reputation: 838946

Python has a NoneType for the None value. None is similar to null in other languages.

>>> type(None)
<type 'NoneType'>

Other languages may use None to mean something else.

Upvotes: 1

Related Questions