Mutable & Immutable Objects in Python | Python for Beginners

Опубликовано: 21 Июль 2021
на канале: Secret Sheru
19
2

Every variable in python holds an instance of an object. There are two types of objects in python i.e. Mutable and Immutable objects. Whenever an object is instantiated, it is assigned a unique object id. The type of the object is defined at the runtime and it can’t be changed afterwards. However, it’s state can be changed if it is a mutable object.

To summarise the difference, mutable objects can change their state or contents and immutable objects can’t change their state or content.

Immutable Objects : These are of in-built types like int, float, bool, string, unicode, tuple. In simple words, an immutable object can’t be changed after it is created.

Mutable Objects : These are of type list, dict, set . Custom classes are generally mutable.

Exception : However, there is an exception in immutability as well.


На этой странице сайта вы можете посмотреть видео онлайн Mutable & Immutable Objects in Python | Python for Beginners длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Secret Sheru 21 Июль 2021, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 19 раз и оно понравилось 2 зрителям. Приятного просмотра!