Monday, 24 June 2019

Immutable

Immutable:

Once we create an object, we can not change in that object. If we try to change then with those changes a new object is created.
This non-changeable is called immutable.


When a object is created, Simple put, a mutable object can be data is changeable after it is created, and an immutable object can't. Objects of built-in types like (int, float, bool, str, tuple, unicode) are immutable. Objects of built-in types like (list, set, dict) are mutable. Custom classes are generally mutable.


Every object reference holds an object data(instance). When an object is created, it is assigned a unique object address(id). Its data type is defined at runtime and once set can never change, However its state can be changed if it is mutable. Simple put, a mutable object can be changed after it is created, and an immutable object can’t.


Next topic:   List
Previous topic: type casting

No comments:

Post a Comment

Files with Exception handling

#Ask the user to take two input integer values var a,b try:     a=int(input("enter any integer value:"))     b=int(input(...