Everything object
Now that we understand that everything is an object and have a little bit of knowledge, let’s pause and look a little bit closer at how Python works with different types of objects.
BTW, have you ever modified a variable without knowing it or wanting to? I mean:
>>> a = 1
>>> b = a
>>> a = 2
>>> b
1
>>>
OK, But what about this?
>>> l = [1, 2, 3]
>>> m = l
>>> l[0] = 'x'
>>> m
['x', 2, 3]
>>>
- Objects and Values
- Aliasing
- Immutable vs mutable types
- Mutation
- Cloning lists
- Python tuples - Immutable but potentially changing
By the end of this project, you should be able to explain to anyone the following concepts without the help of Google.
- What is an object
- What is the difference between a class and an object or instance
- What is the difference between immutable object and mutable object
- What is a reference
- What is an assignment
- What is an alias
- How to know if two variables are identical
- How to know if two variables are linked to the same object
- How to display the variable identifier (which is the memory address in the CPython implementation)
- What is mutable and immutable
- What are the built-in mutable types
- What are the built-in immutable types
- How does Python pass variables to functions