Companies Home Search Profile

Immutability in Python

Focused View

Dan Bader

09:53

341 View
  • 1. Python Immutability Overview.mp4
    00:36
  • 2. Mutable Objects vs Immutable Objects in Python.mp4
    01:18
  • 3. Examples for Mutable and Immutable Objects.mp4
    01:03
  • 4. When to Use Immutable vs Mutable Objects.mp4
    02:40
  • 5. Immutability Quirks and Oddities in Python.mp4
    04:16
  • Description


    In Python, immutable vs mutable data types and objects types can cause some confusion—and weird bugs. With this video course you’ll see what the difference between mutable and immutable data types is in Python, and how you can use it to your advantage in your own programs.

    You’ll also see how to deal with a language quirk in Python that allows objects referenced by immutable types to me modified. Python’s definition of “immutable” can be a bit misleading.

    Basically, the promise of “immutability” on tuples is only partly true. The tuple itself cannot be modified, but objects referenced by the tuple can be. This is sometimes called “non-transitive immutability.”

    If the tuple has an immutable field like a string for example, then it cannot be modified. A mutable field like a list however, can be edited, even if it’s embedded in the “immutable” tuple.

    When the Python documentation refers to an object as being “immutable” they mean the behavior above observed. Other immutable types in Python behave the same way, e.g. namedtuples or frozensets.

    If you’ve ever encountered the following exception and now you want to know why, this is the video course for you:

    More details


    User Reviews
    Rating
    0
    0
    0
    0
    0
    average 0
    Total votes0
    Focused display
    Category

    Dan Bader is the owner and editor in chief of Real Python and the main developer of the realpython.com learning platform. Dan has been writing code for more than 20 years and holds a master’s degree in computer science. He’s the author of Python Tricks, a best selling programming book for intermediate Python developers.

    Hey, I’m Dan Bader and I help Python developers take their coding skills and productivity to the next level. I’m an independent software engineer, author, and speaker. I’ve been writing code for more than two decades—and I’d love to help you become a more proficient Python coder.

    Here’s where you can find me elsewhere on the web:

    I’ve also done some podcast interviews and other media appearances you can check out:

    Learn Python online: Python tutorials for developers of all skill levels, Python books and courses, Python news, code examples, articles, and more.
    • language english
    • Training sessions 5
    • duration 09:53
    • English subtitles has
    • Release Date 2023/01/05