Python Objects, Garbage Collection, and Name Binding Programming Examples

preview_player
Показать описание
Python uses objects to represent everything in your program, such as strings, integers, functions, lists and more.

Objects have 3 properties:
1. Value – Ex: 20, “twenty”, or “20”
2. Type – The object’s type: Integer, string, floating-point, etc.
3. Identity – the identifier name that describes the object

The Python interpreter creates and uses objects as needed to run your code. When an object is no longer used, garbage collection deletes it from memory.

Names are associated to objects via name binding. An object can have one or more name bound to it, and a name is bound to exactly one object. In Python, there are no declarations. The existence of a variable depends on a statement that binds the variable, or, in other words, that sets a name to hold a reference to some object. You can also unbind a variable by resetting the name so it no longer holds a reference.

The type() function returns the type of an object. The type of the object determines if it is mutable (changeable) or immutable (unchangeable). In python, both strings and integers are mutable

The id() function gives the value of an object's identity.

Subscribe to Appficial for more programming videos coming soon. Also, don't forget to click LIKE and comment on the video if it helped you out!
Рекомендации по теме
join shbcf.ru