Overview:
To represent the absence of a value "None" is used in Python. The keyword "None" is the equivalent of "null" or "void" in other programming languages like C and C++. Often "None" is used to initialize any identifier before they are initialized with appropriate values. In Python, the value "None" is of type NoneType. The type NoneType has only one value that is "None".
When a Python function has no value to return, the value returned by the function is None.
Example:
|
class Part: # Before the object is initialised by the constructor it is defined to have a value of None myId = None
def __init__(self, aId_in): self.myId = aId_in
Part1 = Part(12) print("Id of Part1 : {}".format(Part1.myId)) |
Output:
|
Id of Part1 : 12 |