<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rick on Medium]]></title>
        <description><![CDATA[Stories by Rick on Medium]]></description>
        <link>https://medium.com/@11449_17304?source=rss-777925f9a0d4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Rick on Medium</title>
            <link>https://medium.com/@11449_17304?source=rss-777925f9a0d4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 15:31:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@11449_17304/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Python for Dummies: Mutable vs Immutable Objects for Dummies.]]></title>
            <link>https://medium.com/@11449_17304/python-for-dummies-mutable-vs-immutable-objects-for-dummies-9401affb0fe4?source=rss-777925f9a0d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/9401affb0fe4</guid>
            <category><![CDATA[dummies]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Rick]]></dc:creator>
            <pubDate>Sun, 23 Nov 2025 10:39:38 GMT</pubDate>
            <atom:updated>2025-11-23T10:39:38.167Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey there! Today we’re going to talk about one of the most confusing things when you start Python: <strong>some things can change, some things can’t</strong>. Don’t worry — I’ll explain it like you’re 5 (but with code).</p><h3>What is an “object” in Python?</h3><p>Everything in Python is an object: numbers, text, lists… everything! Every object has two super-important details:</p><ul><li>Its <strong>type</strong> (is it a number? a list? a piece of text?)</li><li>Its <strong>ID</strong> (like its home address in your computer’s memory)</li></ul><pre>x = 42<br>print(type(x))    # &lt;class &#39;int&#39;&gt;  → it&#39;s a number<br>print(id(x))      # some big number, like 10919488 → its address</pre><h3>Mutable = Can Change After Birth</h3><p>Think of a Lego house. You can add or remove bricks anytime. That’s <strong>mutable</strong>.</p><p>Common mutable things:</p><ul><li>lists</li><li>dictionaries</li><li>sets</li></ul><pre>my_list = [1, 2, 3]<br>print(my_list)          # [1, 2, 3]<br><br>my_list.append(4)       # I changed it!<br>print(my_list)          # [1, 2, 3, 4]<br><br>print(id(my_list))      # same address before and after → same house, just more bricks!</pre><h3>Immutable = Cannot Change After Birth</h3><p>Think of a baked cake. Once it’s baked, you can’t unbaked it. You can only make a new cake.</p><p>Common immutable things:</p><ul><li>numbers (int, float)</li><li>strings</li><li>tuples</li></ul><pre>name = &quot;alice&quot;<br>name = name.upper()     # looks like I changed it...<br>print(name)             # ALICE → new cake!<br>print(id(&quot;alice&quot;))      # different address<br>print(id(&quot;ALICE&quot;))      # different address → Python made a brand-new string</pre><p>Try this and it will yell at you:</p><pre>my_tuple = (1, 2, 3)<br>my_tuple[0] = 99       # ERROR! Tuples are immutable!  </pre><h3>Why Should You Even Care?</h3><p>Because it can create super sneaky bugs!</p><p>Example with mutable (the dangerous one):</p><pre>groceries = [&quot;milk&quot;, &quot;eggs&quot;]<br>backup = groceries           # I think I&#39;m making a copy...<br>groceries.append(&quot;bread&quot;)<br>print(backup)                # [&#39;milk&#39;, &#39;eggs&#39;, &#39;bread&#39;]  ← Surprise! backup changed too!</pre><p>Both names point to the <strong>same house</strong>. If one person adds furniture, the other sees it.</p><h3>How Python Gives Things to Functions</h3><p>Python doesn’t copy stuff when you send it to a function. It just hands over the <strong>address</strong>.</p><p>Immutable example (totally safe):</p><pre>def add_five(number):<br>    number = number + 5     # makes a brand-new number<br><br>x = 10<br>add_five(x)<br>print(x)                    # still 10! The original never changed</pre><p>Mutable example (watch out!):</p><pre>def add_cheese(my_shopping_list):<br>    my_shopping_list.append(&quot;cheese&quot;)<br>basket = [&quot;bread&quot;, &quot;milk&quot;]<br>add_cheese(basket)<br>print(basket)               # [&#39;bread&#39;, &#39;milk&#39;, &#39;cheese&#39;] ← function changed my basket!</pre><h3>Quick Cheat Sheet You Can Save</h3><pre>| Can change later? | Type          | Examples                    | Safe in functions?          |<br>|-------------------|---------------|-----------------------------|-----------------------------|<br>| Yes (Mutable)     | list, dict, set | [1,2], {&quot;a&quot;:1}, {1,2}    | No — changes affect outside |<br>| No (Immutable)    | int, str, tuple | 5, &quot;hi&quot;, (1,2)           | Yes — original never changes|</pre><p>Save it, screenshot it, tattoo it… you’re now officially immune to 90% of Python “why did my list</p><h3>Final Tip for Dummies</h3><p>Whenever you’re scared of accidentally changing a list, make a real copy:</p><p>Python</p><pre>backup = groceries[:]        # the [:] makes a real copy!<br># or<br>backup = list(groceries)</pre><p>That’s it! Now you understand one of the biggest “gotchas” in Python. Go show off to your friends that you know the difference between mutable and immutable objects. You’re no longer a dummy — you’re a Python wizard in training</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9401affb0fe4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>