Skip to content

Files

Latest commit

98f62bd · Jan 4, 2023

History

History

0x09-python-everything_is_object

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023
Jan 4, 2023

img

Everything object

meme

Background Context

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]
>>> 

meme

Resources

  1. Objects and Values
  2. Aliasing
  3. Immutable vs mutable types
  4. Mutation
  5. Cloning lists
  6. Python tuples - Immutable but potentially changing

Learning objectives

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