<?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 uneeza ismail on Medium]]></title>
        <description><![CDATA[Stories by uneeza ismail on Medium]]></description>
        <link>https://medium.com/@uneezaismail?source=rss-104491ae0341------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-r27VL9ePyHpCFdfGVOgjg.jpeg</url>
            <title>Stories by uneeza ismail on Medium</title>
            <link>https://medium.com/@uneezaismail?source=rss-104491ae0341------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 06:18:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@uneezaismail/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[How LLMs Generate Text and the Role of Model Settings]]></title>
            <link>https://uneezaismail.medium.com/how-llms-generate-text-and-the-role-of-model-settings-fc13072f0b21?source=rss-104491ae0341------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc13072f0b21</guid>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[large-language-models]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <dc:creator><![CDATA[uneeza ismail]]></dc:creator>
            <pubDate>Mon, 15 Sep 2025 15:30:03 GMT</pubDate>
            <atom:updated>2025-09-15T15:48:38.853Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FfIhXF6fReN0lyGl9XDnEQ.png" /></figure><h3>How Does an LLM Generate Text?</h3><p>Large Language Models (LLMs) don’t “think” like humans. They work with <strong>probabilities</strong>.</p><p>Here’s how it works step by step:</p><ol><li><strong>Input</strong>: You give the model a prompt (your question or instruction).</li><li><strong>Tokenization</strong>: The model breaks it into tokens (pieces of words).</li><li><strong>Prediction</strong>: For the next word, the model calculates a <strong>probability distribution</strong> (scores called <em>logits</em>) for all possible words.</li></ol><ul><li>Example: after “The cat is”, probabilities might be:</li></ul><pre>sleeping → 0.70<br>running → 0.20<br>blue → 0.10</pre><p>4.<strong> Selection</strong>: The model picks one word, adds it to the sentence, and repeats until the answer is complete.</p><p>👉 So, LLMs generate text <strong>one word at a time</strong>, guided by probability.</p><h3>What Are Model Settings?</h3><p>Model settings are <strong>controls</strong> that tell the LLM <em>how</em> to choose words from its probability list.</p><p>Without them, the model would always pick the most likely word → safe, but boring and repetitive.</p><p>With them, we can add:</p><ul><li>Creativity</li><li>Variety</li><li>Control</li></ul><h3>Why Do We Need Model Settings?</h3><p>We need them to balance:</p><ul><li><strong>Creativity vs Accuracy</strong></li><li><strong>Predictability vs Surprise</strong></li><li><strong>Repetition vs Diversity</strong></li></ul><p>They let us shape the <em>style</em> of responses, whether we want formal, safe answers or creative, story-like text.</p><h3><strong>The Key Model Settings</strong></h3><h3>1. Temperature :</h3><ul><li>Controls <strong>randomness</strong> in word selection.</li><li><strong>Low temperature (e.g., 0.2)</strong> → usually one word dominates probability, and the model almost always picks it.</li><li><strong>High temperature (e.g., 0.9)</strong> → probabilities flatten, so other words get a fair chance, making output more creative.</li><li><strong>0 temperature</strong> → deterministic: the model always picks the top word.</li></ul><p><strong>Example:</strong><br> Prompt: <em>“Write a tagline for a coffee shop.”</em></p><ul><li>Temp 0.2 → “Fresh coffee served daily.”</li><li>Temp 0.9 → “Awaken your senses, one sip at a time!”</li></ul><p>👉 Think of it like this:</p><ul><li><strong>Low temp</strong> = sharp peak (safe choice).</li><li><strong>High temp</strong> = flat distribution (more variety).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*NH6M-_9b4wiVyMBm8N-ciw.png" /></figure><h3><strong>2. Top-p (Nucleus Sampling)</strong></h3><ul><li>Uses <strong>cumulative probability</strong>.</li><li>Words are sorted by probability, and we keep adding them until the total reaches <em>p</em>.</li><li>Only that set of words is considered.</li></ul><h4><strong>Example</strong>:</h4><h4>Prompt : “The sun is”</h4><p>Probabilities:</p><pre>bright →   0.40<br>hot →      0.25<br>shining →  0.15<br>glowing →  0.10<br>sleeping → 0.05<br>blue →     0.05</pre><p><strong>How top_p works:</strong></p><pre>top-p = 0.5 → {bright, hot}... (0.40 + 0.25 = 0.65)<br><br>top-p = 0.9 → {bright, hot, shining, glowing}... (0.40 + 0.25 + 0.15 + 0.10 = 0.90)<br><br>top-p = 1.0 → all words included</pre><p>👉 Small p = safe &amp; focused.<br> 👉 Large p = more words, more diversity.</p><h3>3. Top-k:</h3><ul><li>Instead of cumulative probability, it just picks from the <strong>top k words</strong>.</li><li>if top_k is 1 it will choose top 1st word and so on.</li></ul><p>Using the same example (<em>“The sun is”</em>):</p><pre>top-k = 1 → {bright} # picked only top 1 word<br><br>top-k = 3 → {bright, hot, shining}  # picked top 3 words and then will randomly choose one word<br>top-k = 5 → {bright, hot, shining, glowing, sleeping} # picked top 5 words and then will randomly choose one word</pre><p>👉 Top-k is about <strong>how many words</strong>, while Top-p is about <strong>how much probability mass.</strong></p><h3>4. Frequency Penalty vs Presence Penalty</h3><p>Both of these are <strong>model settings</strong> that control how repetitive or diverse the text is. They both modify the probability of words <strong>after the logits (raw scores) are generated</strong>. Let’s break them down.</p><h4>Frequency Penalty</h4><p>👉 <strong>What it does:</strong></p><ul><li>The model looks at how many times a word has already appeared in the generated text.</li><li>Then it <strong>multiplies the penalty by that count</strong> and <strong>reduces the probability of that word</strong> in the next step.</li><li>The more often a word has been used, the <strong>heavier the penalty</strong> becomes.</li></ul><p>📌 <strong>Think of it like a teacher saying:</strong></p><blockquote><em>“Okay, you’ve already said ‘pizza’ 3 times. Say something else now!”</em></blockquote><p>Example:</p><p><strong>Prompt:</strong> “Write about your favorite food.”</p><p><strong>Without frequency penalty:</strong></p><blockquote><em>“I love pizza. Pizza is tasty. Pizza is my favorite. Pizza is the best.”</em></blockquote><p>The word <strong>“pizza”</strong> keeps getting picked because it had the highest probability.</p><p><strong>With frequency penalty (e.g., 1.0):</strong></p><blockquote><em>“I love pizza. It’s tasty and one of my favorite foods. I also enjoy pasta sometimes.”</em></blockquote><p>Here the model <strong>reduces the chance of picking “pizza” again</strong> since it’s already appeared multiple times.</p><h4><strong>Behind the scenes (simplified numbers):</strong></h4><ul><li>Suppose probabilities for next word are:</li></ul><pre>pizza: 0.40<br>pasta: 0.30<br>burger: 0.20<br>sushi: 0.10</pre><p>If “pizza” already appeared 3 times, and frequency penalty = 0.1:</p><ul><li>New score for pizza = 0.40 — (0.1 × 3) = 0.10</li></ul><p><strong>(These are adjusted scores; the model will then re-normalize them so they add up to 1.)</strong></p><p>Now new probaility is:</p><pre>pizza: 0.10<br>pasta: 0.30<br>burger: 0.20<br>sushi: 0.10</pre><ul><li>Now probabilities shift, so “pasta” or “burger” become more likely than before.</li></ul><h4>Presence Penalty</h4><p>👉 <strong>What it does:</strong></p><ul><li>Unlike frequency penalty, it doesn’t care <strong>how many times</strong> a word has appeared.</li><li>It only checks <strong>whether the word has appeared at all</strong>.</li><li>If yes → apply a <strong>flat penalty</strong> once, to encourage new words.</li></ul><p>📌 <strong>Think of it like a teacher saying:</strong></p><blockquote><em>“You’ve already mentioned ‘reading’ once. Now try something different instead.”</em></blockquote><p>Example:</p><p><strong>Prompt:</strong> “List hobbies.”</p><p><strong>Without presence penalty:</strong></p><blockquote><em>“Reading, writing, reading, reading, reading…”</em></blockquote><p>Because “reading” had high probability, the model keeps looping on it.</p><p><strong>With presence penalty (e.g., 1.0):</strong></p><blockquote><em>“Reading, painting, hiking, cooking.”</em></blockquote><p>Now once “reading” is used, its probability is reduced for the rest of that generation, pushing the model toward other hobbies.</p><p><strong>Behind the scenes (simplified numbers):</strong></p><ul><li>Probabilities for next word:</li></ul><pre>reading: 0.50<br>painting: 0.25<br>hiking: 0.15<br>cooking: 0.10</pre><p>After using “reading” once with presence penalty = 0.3:</p><ul><li>New score for reading = 0.50–0.30 = 0.20</li></ul><p>now Probability will become:</p><pre>reading: 0.20<br>painting: 0.25<br>hiking: 0.15<br>cooking: 0.10</pre><ul><li>“Painting” becomes more competitive, and the model is nudged to <strong>explore diversity</strong>.</li></ul><h3>Conclusion</h3><p>Model settings are the fine-tuning tools of language models. They don’t alter what the model knows, but they decide how that knowledge is expressed , precise or playful, predictable or surprising, repetitive or refreshing. <br>Mastering these settings means turning raw probability into purposeful communication, where every response feels not just generated, but crafted.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc13072f0b21" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Circular Mystery of Python’s type and object — Explained Simply]]></title>
            <link>https://uneezaismail.medium.com/the-circular-mystery-of-pythons-type-and-object-explained-simply-7265c8e49e6c?source=rss-104491ae0341------2</link>
            <guid isPermaLink="false">https://medium.com/p/7265c8e49e6c</guid>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-class]]></category>
            <category><![CDATA[python-object]]></category>
            <dc:creator><![CDATA[uneeza ismail]]></dc:creator>
            <pubDate>Sun, 18 May 2025 14:18:37 GMT</pubDate>
            <atom:updated>2025-05-20T10:18:39.416Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Circular Mystery of Python’s type and object…. Explained Simply</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wybTa811UrDTa1U-mGuvTA.png" /></figure><p>When we dive into Python’s class system, two magical things pop up: <strong>type</strong> and <strong>object</strong>.</p><p>But wait… the deeper you go, the more it feels like a paradox:</p><ul><li>type <strong>creates</strong> object</li><li>type also <strong>inherits</strong> from object</li><li>And <strong>type</strong> is somehow an <strong>instance of itself</strong>?!</li></ul><p>Let’s unravel this mystery together.</p><h3>What Are <strong>type</strong> and object?</h3><p>In Python:</p><ul><li><strong>object</strong> is the <strong>base class of all classes</strong>. Everything ultimately inherits from <strong>object</strong>.</li></ul><pre>class A:<br>    pass<br><br>print(isinstance(A(), object))  # True</pre><ul><li><strong>type</strong> is the <strong>metaclass that creates classes</strong> in Python.</li></ul><pre>A = type(&quot;A&quot;, (), {})<br>print(type(A))  # &lt;class &#39;type&#39;&gt;</pre><p>So far, so good. But things get weird when we dig deeper:</p><pre>print(isinstance(object, type))  # True ✅<br>print(isinstance(type, type))    # True ✅<br>print(issubclass(type, object))  # True ✅<br>print(issubclass(object, type))  # False ❌</pre><p>Hmm 🤔… This looks circular.</p><h3>The “Circular Relationship”</h3><p>Here’s the loop we notice:</p><ul><li><strong>type</strong> <strong>creates all classes</strong> (including object ).</li><li>But <strong>type</strong> is itself a class, so it’s an <strong>instance of type</strong>.</li><li>type <strong>inherits from</strong> object (meaning it <strong>is-a</strong> object).</li><li>But <strong>object</strong> is created by <strong>type</strong> (meaning it is <strong>created-by</strong> type).</li></ul><p>It’s like saying:</p><blockquote><em>“The parent created the child, but the parent is also a child of the child.”</em></blockquote><p>Wait… what?</p><h3>Understanding Inheritance vs Instantiation</h3><p>To clear the confusion, we need to separate two important ideas:</p><h4>Inheritance: What something is</h4><p>This means a class takes properties and behavior from another class.<br> For example, if one class inherits from another, it means:</p><blockquote><em>“I am a kind of that class.”</em></blockquote><p>Like saying:</p><blockquote><em>A dog is a kind of animal.</em></blockquote><h4>Instantiation: How something is made</h4><p>This means creating an object from a class.<br> So when we instantiate, we’re saying:</p><blockquote><em>“This object was made using that class.”</em></blockquote><p>Like saying:</p><blockquote><em>This puppy was made from the dog blueprint.</em></blockquote><h3>Now back to type and object:</h3><ul><li><strong>type </strong>is a kind of <strong>object </strong>→ <em>(inheritance)</em></li><li><strong>object </strong>was created by <strong>type</strong>→ <em>(instantiation)</em></li><li><strong>type </strong>even created <strong>itself </strong>→ <em>(yes, that’s possible in Python!)</em></li></ul><p><strong><em>So, don’t mix them up:</em></strong><br> <strong>Inheritance</strong> is about <em>what it is</em>, and<br> <strong>Instantiation</strong> is about <em>who made it</em>.</p><h3>How Python Solves This: The Bootstrap (Fully Explained)</h3><p>This is where Python pulls off one of its <strong>smartest tricks</strong>: <strong>bootstrapping</strong>.</p><p>Since defining <strong>type</strong> and <strong>object</strong> using regular Python code would lead to circular confusion, Python takes a shortcut at the very bottom level — in <strong>C</strong> (specifically, in the CPython implementation).</p><p>But before we dive deeper…</p><h3>What is Bootstrapping?</h3><p>In programming, <strong>bootstrapping</strong> means starting a system with <strong>minimal setup</strong> and then building more complex parts on top of it.</p><p>In Python’s case, it’s about how the core classes — <strong>type</strong> and <strong>object</strong> — are <strong>created</strong>, even though they seem to <strong>depend on each other</strong>.</p><p>If Python tried to define them using normal Python code, it would hit a roadblock — because neither one would exist yet to define the other.</p><p>So… how does Python pull this off without crashing?</p><h3>The Bootstrap in CPython (Python’s Core)</h3><p>Here’s the clever part:</p><p>Python’s most widely used interpreter, <strong>CPython</strong>, is written in the C language.</p><p>At the <strong>very lowest level</strong> of CPython, the two fundamental classes — <strong>type</strong> and <strong>object</strong> — are <strong>manually created</strong> in C. They aren’t built using class definitions like we’re used to in Python.</p><p>This lets Python <strong>“cheat” just once</strong>, to get the system started — and then the rest of Python’s class system builds up cleanly from there.</p><h3>How Python Wires type and object Together</h3><p>Behind the scenes, Python connects <strong>type </strong>and <strong>object </strong>like this:</p><ul><li><strong>type </strong>is an instance of <strong>itself</strong> → type.__class__ = type</li><li><strong>object </strong>is an instance of <strong>type</strong>→ object.__class__ = type</li><li><strong>type </strong>inherits from <strong>object</strong>→ type.__base__ = object</li></ul><p>What this means:</p><ul><li><strong>type </strong>is its own type — strange but true!</li><li><strong>object </strong>is created by <strong>type</strong>, like all other classes.</li><li><strong>type </strong>is a kind of <strong>object</strong>, so it gets basic class behavior.</li></ul><p>That’s why this works:</p><pre>issubclass(type, object)  # True ✅</pre><p>Even though <strong>type </strong>creates <strong>object</strong>, it also inherits from it — a clever setup made possible by Python’s core (written in C).</p><h3>Why This Works (Even Though It Looks illogical)</h3><p>If Python tried to define this setup using <strong>regular class syntax</strong>, it would run into <strong>a chicken-and-egg problem</strong>:</p><ul><li>You can’t define <strong>object</strong> without <strong>type</strong>.</li><li>You can’t define <strong>type</strong> without <strong>object</strong>.</li></ul><p>It would be an infinite loop.</p><p>But Python sidesteps this by <strong>bootstrapping the very first pieces</strong> — <strong>type</strong> and <strong>object</strong> — in C. Once those are in place, everything else follows cleanly using Python’s normal rules.</p><p>This is what makes the “circular” relationship possible:</p><ul><li>object is <strong>created by</strong> type</li><li>type is a <strong>subclass of</strong> object</li><li>type is an <strong>instance of itself</strong></li></ul><p>It’s kind of like two people saying:</p><blockquote><em>“You created me, but I also define what you are.”</em></blockquote><h3>Confusing? Yes.</h3><h3>Clever? Absolutely.</h3><p>This low-level magic is <strong>one-time setup</strong> — done deep inside CPython — that allows Python to have a fully consistent, object-oriented system built on top of it.</p><p>After that, <strong>everything in Python</strong> — from your custom classes to built-in types like <strong>int</strong>, <strong>str</strong>, <strong>list</strong> — falls into place beautifully.</p><p>And all thanks to a bit of elegant trickery at the very start.</p><h3>Final Thoughts</h3><p>The relationship between <strong>type</strong> and <strong>object</strong> is a beautiful, circular dance — the kind you’d only find in a language that blends object-oriented programming with metaprogramming so elegantly.</p><p>So the next time someone asks:</p><blockquote><em>“</em>Who came first — <strong>type</strong> or <strong>object</strong>?”</blockquote><p>You can confidently answer:</p><blockquote><em>“They were both created at the same time, by the Python developers… with a little help from C.”</em></blockquote><p><strong><em>Enjoyed the read?</em></strong> Follow for more simple takes on complex Python stuff!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7265c8e49e6c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unpacking the Real Magic of Python: Why Everything’s an Object]]></title>
            <link>https://uneezaismail.medium.com/unpacking-the-real-magic-of-python-why-everythings-an-object-e0a1c0e911af?source=rss-104491ae0341------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0a1c0e911af</guid>
            <category><![CDATA[oop-python]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[oop-concepts]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[uneeza ismail]]></dc:creator>
            <pubDate>Sun, 18 May 2025 13:24:21 GMT</pubDate>
            <atom:updated>2025-05-20T11:00:03.954Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HFcv5UU2Xj8ludpnvACFwQ.png" /></figure><p>If you’ve just started learning Python , you’ve probably heard this mysterious phrase:</p><blockquote><strong>“Everything in Python is an object.”</strong></blockquote><p>It sounds cool, but what does it really mean? And why is it such a big deal?</p><p>Let’s peel back the layers and explore the <em>real magic</em> at Python’s core — where objects, classes, types, and metaclasses all dance together. I promise it’s more exciting than you think.</p><h3>What Is an Object, Anyway?</h3><p>Think of an <strong>object</strong> as a <em>recipe</em> you’ve prepared: it has ingredients (data) and steps you can perform (methods).</p><p>Numbers, words, lists — everything you interact with in Python is an object.</p><pre>print(isinstance(42, object))     # True<br>print(isinstance(&quot;hello&quot;, object)) # True</pre><p>This is why Python treats almost everything the same way — it’s all objects under the hood.</p><h3>Classes: The Recipes for Objects</h3><p>If objects are the <strong>prepared dishes</strong>, then <strong>classes</strong> are the <strong>recipes</strong> that describe how to make them.</p><pre>class Recipe:<br>    def __init__(self, name):<br>        self.name = name<br><br>pasta = Recipe(&quot;Pasta&quot;)<br>print(type(pasta))  # &lt;class &#39;__main__.Recipe&#39;&gt;</pre><p>Here, <strong>pasta </strong>is an object (a dish) created from the <strong>Recipe </strong>class. Simple enough, right?</p><h3>But Wait… Classes Are Objects Too?!</h3><p>Here’s where the real magic begins: <strong>Classes themselves are also objects</strong>.</p><p>Yes, even the <strong>recipe itself</strong> was written using another tool — the <strong>recipe book template</strong>.</p><pre>print(type(Recipe))  # &lt;class &#39;type&#39;&gt;<br>print(type(int))     # &lt;class &#39;type&#39;&gt;</pre><p>This means that classes (like <strong>Recipe </strong>and <strong>int</strong>) are actually created by a built-in object called <strong>type</strong>.</p><h3>Meet type: The Chef That Writes Recipes</h3><p>If objects are <strong>dishes</strong>, and classes are <strong>recipes</strong>, then <strong>metaclasses</strong> are the <strong>chefs</strong> who write those recipes.</p><ul><li><strong>type </strong>is the <em>default chef</em> in Python.</li><li>It creates the recipe (class) for how your objects should be made.</li></ul><p>And here’s the craziest part:</p><pre>print(type(type))  # &lt;class &#39;type&#39;&gt;</pre><p>Yes — <strong>type </strong>is an instance of itself.<br>That’s like a chef who trained themselves, wrote their own cookbook, and teaches others to do the same.<br>Mind blown?</p><h3>How Python Creates an Object: Step by Step</h3><p>When you run:</p><pre>pasta = Recipe(&quot;Pasta&quot;)</pre><p>Python secretly does two things:</p><ol><li><strong>__new__</strong>: The empty dish is created.</li><li><strong>__init__</strong>: The dish is filled with the recipe&#39;s ingredients.</li></ol><pre>class Recipe:<br>    def __new__(cls, *args, **kwargs):<br>        print(&quot;Creating dish...&quot;)<br>        return super().__new__(cls)<br>    <br>    def __init__(self, name):<br>        print(&quot;Filling with ingredients...&quot;)<br>        self.name = name<br><br><br>pasta = Recipe(&quot;Pasta&quot;)</pre><p><strong>Output:</strong></p><pre>Creating dish...<br>Filling with ingredients...</pre><p>So, <strong>__new__</strong> is like setting up the dish, and <strong>__init__</strong> is decorating and adding the flavors.</p><h3>How Python Creates Classes: Behind the Scenes</h3><p>When you write:</p><pre>class Recipe:<br>    def __init__(self, name):<br>        self.name = name</pre><p>Python is actually doing this:</p><pre>Recipe = type(&quot;Recipe&quot;, (object,), {<br>    &quot;__init__&quot;: lambda self, name: setattr(self, &quot;name&quot;, name)<br>})</pre><p>That’s right — the class you wrote is just a dynamic object, built using the <strong>type </strong>metaclass.</p><h3>Custom Metaclasses: Becoming the Chef</h3><p>Now that you know <strong>type </strong>is the default <strong>metaclass</strong>, what if you want to customize how classes are created?<br>Good news — Python lets you become the chef yourself.</p><pre>class MyMeta(type):<br>    def __new__(cls, name, bases, attrs):<br>        print(f&quot;Creating class: {name}&quot;)<br>        return super().__new__(cls, name, bases, attrs)<br><br>class Recipe(metaclass=MyMeta):<br>    def __init__(self, name):<br>        self.name = name<br><br><br>pasta = Recipe(&quot;Pasta&quot;)</pre><p>Output:</p><pre>Creating class: Recipe</pre><p><strong>That means</strong>: <em>Even before you create an object, Python checks with the chef (your metaclass) to see how to build the recipe itself.</em></p><h3><strong>Wait, I Have One More Twist for You!</strong></h3><p>We’ve all used int(), str(), list(), and other built-ins like they’re just functions, right? You probably do it every day without giving it a second thought.</p><p>But here’s the kicker: those aren’t actually functions.</p><pre>print(type(int))   # &lt;class &#39;type&#39;&gt;<br>print(type(str))   # &lt;class &#39;type&#39;&gt;<br>print(type(list))  # &lt;class &#39;type&#39;&gt;</pre><p>They’re classes — built-in classes — just like the ones you create with <strong>class</strong>. So why do they look and behave like functions?</p><p>Because classes in Python are <strong>callable</strong> objects. When you do something like int(&quot;42&quot;) or list(&quot;abc&quot;), you’re not calling a plain old function — you’re creating a new instance of a class using its special __call__ method. This method lets classes behave like functions, so the parentheses <strong>()</strong> work seamlessly.</p><p><strong><em>One more interesting fact….</em></strong><br>These built-in classes don’t follow the usual <strong>PascalCase</strong> naming convention (like <strong>Int</strong>,<strong> Str ,List</strong>) because they were defined <em>long before</em> PEP 8 became the style guide we follow today. Changing their names now would break tons of existing Python code — so they’ve stuck around with their original lowercase names.</p><p>So next time you write:</p><pre>x = int(&quot;123&quot;)</pre><p>Remember — you’re actually creating a new instance of the <strong>int </strong>class, not just calling a function. Python’s design makes it look simple, but there’s some clever magic happening under the hood! 😄</p><h3>Final Thoughts</h3><p>Understanding that <strong>everything in Python is an object</strong>, and that <strong>classes themselves are made by other classes (metaclasses)</strong>, unlocks a deeper level of Python’s power.</p><p>It might feel like magic — but it’s actually a beautifully structured design.</p><p>Next time you define a class, just remember:<br>You’re not just writing a recipe — you’re calling the chef! 👩‍🍳👨‍🍳</p><p><em>Curious about more Python insights like this?</em></p><p>Follow for more simple explanations of complex concepts. <br>Let’s make Python feel like second nature. 🐍</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0a1c0e911af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generative AI: The Tech That’s Making Machines Dream]]></title>
            <link>https://uneezaismail.medium.com/generative-ai-the-tech-thats-making-machines-dream-a3eabf7fb865?source=rss-104491ae0341------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3eabf7fb865</guid>
            <category><![CDATA[generative-ai-use-cases]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <dc:creator><![CDATA[uneeza ismail]]></dc:creator>
            <pubDate>Tue, 06 May 2025 18:23:19 GMT</pubDate>
            <atom:updated>2025-05-06T18:37:28.331Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*A4ZRzRk6ay93Qcz4aPcvmA.jpeg" /></figure><p><em>Imagine a world where machines don’t just follow orders, but create—where AI doesn’t just analyze data but brings ideas to life like an artist, musician, or even a coder. Welcome to the exciting world of Generative AI, where machines are now designing, writing, composing, and creating content that is strikingly human-like.</em></p><p>Whether you’re a tech enthusiast or a creative at heart, buckle up because this is going to be an amazing journey into the future of creativity, innovation, and technology. Ready to dive in and discover how AI is transforming the world? Let’s get started!</p><h3>What the Heck Is Generative AI?</h3><p>Generative AI might sound like sci-fi, but it’s very real—and it’s changing everything. Imagine telling a computer, “Create a song,” or “Make me a picture of a cat riding a skateboard,” and boom—it does exactly that. Magic? Almost! It&#39;s Generative AI—the frontier where machines don’t just analyze data but generate entirely new ideas, designs, texts, music, and more.</p><p>Here’s what it can do:</p><ul><li><strong>Text</strong>: AI that can write blog posts, stories, poetry, and even entire books.</li><li><strong>Art</strong>: AI creating stunning visuals and designs out of thin air.</li><li><strong>Music</strong>: AI crafting original melodies and soundtracks.</li><li><strong>Code</strong>: Yes, AI can even write your code for you.</li><li><strong>Videos</strong>: From deepfakes to AI-generated animations, the possibilities are endless.</li></ul><p>The more you interact with it, the smarter it gets. Welcome to the future of creativity!</p><h3>How Does Generative AI Actually Work?</h3><p>Generative AI is powered by deep learning—think of it as the AI equivalent of a brain. It’s made up of layers of artificial neurons (just like your brain!) that process data and learn complex patterns. Let’s break it down:</p><ol><li><strong>Deep Learning—AI that Thinks Like Us</strong> <br>Generative AI is incredibly smart because it learns from millions (or even billions) of data points. Imagine a student constantly studying to perfect their craft. The more it learns, the more creative it becomes.</li><li><strong>Training Data—The Brain Food </strong><br>Generative AI doesn’t wake up knowing everything. It learns by devouring massive amounts of data—articles, pictures, videos, and more. The more data it has, the better it gets at creating original content that’s shockingly close to what humans would make.</li><li><strong>Foundation Models—AI’s Powerhouse </strong><br>Big AI models like GPT-3 or Google’s Gemini are the superheroes of Generative AI. These massive models are trained on vast datasets, giving them the ability to create and understand almost anything.</li><li><strong>Prompting—Your Ticket to AI Magic</strong> <br>All you need to do is give the AI a prompt. Whether it’s a question, an idea, or a creative request, the AI takes your input and generates something amazing. It’s like giving the AI a brief and watching it bring your ideas to life!</li></ol><h3>Why is Generative AI So Epic?</h3><p>Generative AI isn’t just changing the game—it’s creating a whole new one.</p><p>Here’s why it’s so powerful:</p><ol><li><strong>It’s Not Just Repeating, It’s Innovating </strong><br>Unlike other types of AI that just follow pre-set rules, Generative AI learns patterns and spins them into something brand-new. It can create entirely new art styles, music compositions, or even languages. Every creation is unique!</li><li><strong>It Gets Smarter and Smarter </strong><br>The more you use it, the better it gets. It’s like an artist or coder who gets better the more they practice—AI keeps learning, adapting, and improving, making its creations even more brilliant.</li><li><strong>It Understands Context, Emotion, and Style </strong><br>Generative AI isn’t just random—it understands the context behind your request. It knows what a &quot;funny tweet&quot; should sound like, or how to write an emotional blog post, creating content that feels human.</li><li><strong>It’s Breaking Boundaries</strong> <br>Generative AI is pushing the boundaries of creativity and technology. It’s unlocking new possibilities in art, science, and entertainment, and enabling innovations we never imagined.</li></ol><p>🎧 <strong>Generative AI Is Everywhere—Here’s How It’s Changing the Game</strong></p><p>Generative AI isn’t just a trend; it’s already revolutionizing industries across the globe. Here’s how it’s making an impact:</p><ul><li><strong>Content Creation</strong>: Writing blogs, stories, and social media posts with ease.</li><li><strong>Design</strong>: Creating logos, website templates, and digital art without breaking a sweat.</li><li><strong>Music &amp; Entertainment</strong>: From AI-generated music to movie scripts, AI is changing how we experience entertainment.</li><li><strong>Coding</strong>: AI is automating repetitive tasks and helping developers generate code faster.</li><li><strong>Healthcare</strong>: AI is analyzing patient data, diagnosing diseases, and even discovering new treatments.</li><li><strong>Customer Support</strong>: AI chatbots are handling customer queries with speed and efficiency.</li></ul><p>And that’s just the beginning!</p><p>⚠ <em>But Wait—There’s a Dark Side to AI (Don’t Panic, It’s Manageable!)</em></p><p>Like all powerful tools, Generative AI comes with some risks. But don’t worry, we can manage them:</p><ul><li><strong>Fake Content</strong>: Deepfakes and misinformation are real threats. But with proper regulation and awareness, we can minimize these risks.</li><li><strong>Bias in AI</strong>: If the data AI is trained on is biased, the AI can be too. Ensuring diverse and representative data is key.</li><li><strong>Job Loss</strong>: As AI takes over more creative and repetitive tasks, it might shift the workforce. But it also opens new opportunities for human-AI collaboration.</li></ul><p>The key is using Generative AI ethically and responsibly to ensure it’s a force for good.</p><h3>What’s Next for Generative AI?</h3><p>Hold on tight, because the future of Generative AI is mind-blowing. Here’s what we can expect:</p><ul><li><strong>Personalized Learning</strong>: AI will create customized educational experiences for everyone, making learning smarter and more effective.</li><li><strong>AI-Generated Reality</strong>: Virtual worlds and real-time content generation will blur the lines between reality and digital.</li><li><strong>More Creativity</strong>: As AI advances, it’ll become your ultimate creative collaborator, bringing your wildest ideas to life.</li></ul><p><em>Ready to Start Creating with Generative AI?</em></p><p>The future of creativity is already here—and it’s powered by AI. Whether you’re a beginner, a creator, or just someone curious about technology, diving into the world of Generative AI will change the way you think, create, and innovate.</p><p><strong>Want to learn more?</strong> Check out these awesome resources:</p><ul><li><strong>OpenAI</strong>: <a href="https://openai.com/">https://openai.com/</a></li><li><strong>DeepMind</strong>: <a href="https://deepmind.google/">https://deepmind.google/</a></li><li><strong>Hugging Face</strong>: <a href="https://huggingface.co/">https://huggingface.co/</a></li><li><strong>Stanford’s AI Index Report</strong>: <a href="https://aiindex.stanford.edu/">https://aiindex.stanford.edu/</a></li><li><strong>MIT Technology Review on AI:</strong> <a href="https://www.technologyreview.com/">https://www.technologyreview.com/</a></li></ul><p><strong>Ready to create the future?</strong> <em>The power is in your hands—and it’s just a prompt away</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3eabf7fb865" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Do Sets Require Hashable Elements but Lists Don’t?]]></title>
            <link>https://uneezaismail.medium.com/why-do-sets-require-hashable-elements-but-lists-dont-e6e5337dad01?source=rss-104491ae0341------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6e5337dad01</guid>
            <category><![CDATA[python-tips]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[uneeza ismail]]></dc:creator>
            <pubDate>Mon, 24 Mar 2025 11:53:27 GMT</pubDate>
            <atom:updated>2025-03-24T12:21:31.936Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nJ4Q4qdL-tajC5SxQh8RbQ.png" /></figure><h3>Introduction</h3><p>If you’ve ever tried adding a list inside a set, you might have run into this error:</p><pre>set1 = {1, 2, [3, 4]}  # ❌ TypeError: unhashable type: &#39;list&#39;</pre><p>But why does this happen?</p><ul><li><strong>Both sets and lists can contain immutable elements like numbers or strings.</strong></li><li><strong>Both sets and lists are mutable themselves.</strong></li></ul><p>So why do set elements have to be hashable, but list elements don’t?</p><p>This question confuses many Python beginners, so let’s break it down step by step.</p><h3># What Are Lists and Sets in Python?</h3><ul><li><strong>Lists (</strong><strong>[ ])</strong> store items in an ordered sequence and allow duplicates. You can modify them using indexing.</li></ul><pre>my_list = [1, 2, 3, 4] <br>my_list[0] = 10  # ✅ Allowed: Lists are mutable <br>print(my_list)   # Output: [10, 2, 3, 4]</pre><ul><li><strong>Sets (</strong><strong>{ })</strong> store unique values and use hashing to check if an element already exists.</li></ul><pre>my_set = {1, 2, 3, 4} my_set.add(5)  # ✅ Allowed: Sets are mutable print(my_set)   # Output: {1, 2, 3, 4, 5}</pre><h3># What Does It Mean to Be Hashable?</h3><p>In Python, an object is <strong>hashable</strong> if:</p><ul><li><strong>It has a unique hash value that doesn’t change.</strong></li><li><strong>It can be used as a key in a dictionary or stored in a set.</strong></li></ul><p>We can check if something is hashable using hash():</p><pre>print(hash(1))      # ✅ Works (Integers are hashable) print(hash(&quot;hello&quot;)) # ✅ Works (Strings are hashable) print(hash((1, 2, 3)))  # ✅ Works (Tuples are hashable) print(hash([1, 2, 3]))  # ❌ TypeError: unhashable type: &#39;list&#39;</pre><h3>Are Sets Themselves Hashable?</h3><p><strong><em>Common Misconception:</em></strong><br> ❌ “Sets are hashable.”</p><p><strong><em>Correct Explanation:</em></strong><br> Sets themselves are <strong>NOT</strong> hashable because they are mutable.<br> Only set elements must be hashable, <strong>NOT</strong> the set itself.</p><p>Example:</p><pre>set1 = {1, 2, 3}<br>print(hash(set1))  # ❌ TypeError: unhashable type: &#39;set&#39;</pre><ul><li>Sets are mutable, so they are <strong>NOT</strong> hashable.</li><li>But their elements <strong>must</strong> be hashable!</li></ul><h3># Why Do Sets Require Hashable Elements?</h3><ul><li>Lists [ ] store items by position (index-based) and do not use hashing.</li><li>Sets { } store items by their hash values, allowing for fast lookups and preventing duplicates.</li></ul><h3><em>Direct Answer to the Confusing Part:</em></h3><p>The reason sets require hashable elements while lists don’t is that sets use a different storage mechanism.</p><ul><li><strong>Lists Do Not Require Hashing</strong></li><li>Lists store elements <strong>in order</strong> and allow duplicates.</li><li>Python does not need to hash them — it just keeps track of their position.</li></ul><pre>list1 = [1, 2, [3, 4]]  # ✅ Allowed: Lists can store mutable elements</pre><ul><li>Lists do not need hashable elements because they store elements <strong>sequentially (by index).</strong></li><li><strong>Sets Use Hashing to Store Elements</strong></li><li>Sets store elements unordered <strong>using hashing.</strong></li><li>If sets allowed <strong>unhashable</strong> elements (like lists), Python would not be able to track them efficiently.</li></ul><pre>set1 = {1, 2, [3, 4]}  # ❌ TypeError: unhashable type: &#39;list&#39;</pre><ul><li>This fails because lists are mutable and do not have a fixed hash.</li></ul><h3># Breaking It Down with an Example</h3><p>You might think:<br> <em>“Wait! Both lists and sets are mutable, and both can hold immutable elements. So why does one require hashable elements while the other doesn’t?”</em></p><p>Let’s break it down with your exact example:</p><pre>set1 = {1, 2, 3, 4}<br>list1 = [1, 2, 3, 4]</pre><h3>In the above example:</h3><ul><li>Both the set and list contain immutable values (<strong>integers</strong>).</li><li>Both are <strong>mutable</strong>, meaning we can modify them.</li></ul><p>But here’s where the difference comes in:</p><ul><li><strong>You can modify a list’s elements directly:</strong></li></ul><pre>list1[0] = 6  # ✅ Works print(list1)  # Output: [6, 2, 3, 4]</pre><ul><li><strong>You cannot modify a set’s elements directly because they are stored using hashing:</strong></li></ul><pre>set1[0] = 6  # ❌ TypeError: &#39;set&#39; object does not support indexing</pre><h3>The Fundamental Difference:</h3><ul><li><strong>Lists </strong>allow <strong>modification by index</strong>, so elements don’t need to be hashable<strong>.</strong></li><li><strong>Sets</strong> don’t allow <strong>direct modification</strong> and<strong> rely on hashing</strong>, so elements must be hashable<strong>.</strong></li></ul><h3># How Can You Store a List-Like Object in a Set?</h3><p>If you need to store a <strong>list-like</strong> object inside a set, use a frozenset, which is an immutable version of a set.</p><pre>fs = frozenset([1, 2, 3])<br>my_set = {fs}  # ✅ Works because frozensets are immutable<br>print(my_set)   # Output: {frozenset({1, 2, 3})}</pre><ul><li>Since frozenset cannot be changed, it has a fixed hash, making it <strong>safe</strong> to store inside a set.</li></ul><h3># What Happens When You Modify a Set?</h3><p>Now, let’s test something interesting:<br> <strong>Will a set’s hash change when we add a new element?</strong></p><p><strong><em>This is a trick question!</em></strong></p><p>A <strong>set does not have a hash in the first place!</strong></p><pre>my_set = {1, 2, 3}<br>print(hash(my_set))  # ❌ TypeError: unhashable type: &#39;set&#39;</pre><ul><li>Since sets are <strong>mutable</strong>, Python does <strong>not</strong> allow hashing them at all.</li></ul><p>But internally, Python <strong>recomputes the hash table</strong> when we modify a set:</p><pre>my_set.add(4)  # ✅ Allowed<br>print(my_set)   # Output: {1, 2, 3, 4}</pre><h3>KEY TAKEAWAYS:</h3><ul><li><strong>Sets themselves are NOT hashable, but their elements must be hashable.</strong></li><li><strong>Lists do not require hashable elements because they store elements by position (index).</strong></li><li><strong>Sets require hashable elements because they store elements using hashing.</strong></li><li><strong>Lists can contain mutable elements (like another list), but sets cannot.</strong></li><li><strong>If you need a hashable “list,” use a </strong><strong>frozenset instead.</strong></li></ul><p>Now, the next time you see this error:</p><pre>set1 = {1, 2, [3, 4]}  # ❌ TypeError: unhashable type: &#39;list&#39;</pre><p>You’ll know <strong>exactly</strong> why it happens!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6e5337dad01" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[# Understanding Python’s Internal Virtual Machine (PVM) – A Deep Dive]]></title>
            <link>https://uneezaismail.medium.com/understanding-pythons-internal-virtual-machine-pvm-a-deep-dive-b2767bc2eb9d?source=rss-104491ae0341------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2767bc2eb9d</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[uneeza ismail]]></dc:creator>
            <pubDate>Sun, 16 Feb 2025 08:19:26 GMT</pubDate>
            <atom:updated>2025-02-16T10:06:17.486Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Understanding Python’s Internal Virtual Machine (PVM) – A Deep Dive</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*QsXPwyqOX_-RoWKDy9Sllw.jpeg" /></figure><p>Python is one of the most popular programming languages, known for its simplicity, readability, and versatility. But have you ever wondered how Python executes your code? Behind the scenes, Python has an Internal Virtual Machine, known as the Python Virtual Machine (PVM), that plays a crucial role in executing your programs. In this article, we will explore how Python’s internal VM works in a simple and easy-to-understand way.</p><h3><strong>What is the Python Virtual Machine (PVM)?</strong></h3><p>The Python Virtual Machine (PVM) is the core execution engine of Python. It takes Python bytecode and runs it on your computer. This makes Python platform-independent, meaning that a program written on one system can run on another without modifications.</p><p>Think of the PVM as an interpreter that reads and executes your program step by step. It ensures that your code is understood and executed correctly by managing variables, memory, and function calls.</p><h3><strong>How Does the Python Virtual Machine Work?</strong></h3><p>Python’s execution process can be broken down into four key steps:</p><p><strong>1. Writing the Python Code</strong></p><p>When you write a Python script, you are writing in a high-level, human-readable language. Example:</p><pre>print(&quot;Hello, World!&quot;)</pre><p>This code is easy for humans to understand but not directly executable by a computer.</p><p><strong>2. Compilation to Bytecode</strong></p><p>Before execution, Python compiles the high-level code into bytecode. Bytecode is an intermediate representation of the code that is not directly understandable by the computer but is optimized for execution.</p><ul><li>This compilation happens automatically when you run a Python script.</li><li>The compiled bytecode files are usually stored with a .pyc or .pyo extension inside the __pycache__ folder.</li></ul><p>Example:</p><pre>print(&quot;Hello, World!&quot;)</pre><p>gets converted into something like:</p><pre>LOAD_GLOBAL 0 (print)<br>LOAD_CONST 1 (’Hello, World!’)<br>CALL_FUNCTION 1<br>POP_TOP</pre><p>This is Python’s bytecode representation of the print statement.</p><p><strong>3. Execution by the Python Virtual Machine (PVM)</strong></p><p>After compiling to bytecode, the PVM reads and executes each instruction step by step. The PVM serves as the brain of Python, interpreting and running bytecode instructions.</p><p>The PVM is responsible for:</p><ul><li>Managing memory and variables.</li><li>Handling function calls and returns.</li><li>Performing operations like loops and conditionals.</li><li>Interacting with the system (e.g., displaying output, reading files, networking, etc.).</li></ul><p><strong>4. Producing Output</strong></p><p>Once the PVM completes execution, the final output is displayed on the screen, written to a file, or processed in another way.</p><p>Example:</p><pre>print(&quot;Hello, World!&quot;)</pre><p>The output on your terminal:</p><pre>Hello, World!</pre><p>This is the final step, where Python interacts with your operating system to provide the expected result.</p><h3><strong>Why is the Python Virtual Machine Important?</strong></h3><p><strong>1. Cross-Platform Execution</strong></p><p>Since Python converts code into an intermediate bytecode format, you can write your program on Windows and run it on Linux or macOS without changes.</p><p><strong>2. Efficiency and Optimization</strong></p><p>The PVM optimizes execution by caching compiled bytecode. The next time you run the same script, Python reuses the cached bytecode instead of recompiling.</p><p><strong>3. Automatic Memory Management</strong></p><p>The PVM includes garbage collection and memory management, making Python efficient in handling resources.</p><p><strong>Understanding PVM with a Simple Analogy</strong></p><p>Think of Python’s execution process as a cooking recipe:</p><ul><li>You write the recipe (Python script).</li><li>The recipe is converted into a step-by-step cooking guide (bytecode).</li><li>A chef (PVM) reads the guide and follows the instructions to cook the dish (execute the program).</li><li>You get the final meal (output).</li></ul><p>This analogy simplifies the role of the Python Virtual Machine in making code executable.</p><p><strong>Conclusion</strong></p><p>The Python Virtual Machine (PVM) is a crucial part of Python’s execution process. It takes compiled bytecode and runs it efficiently on different systems. Understanding the PVM helps developers optimize their code, debug errors, and make better use of Python’s capabilities.</p><p>Next time you run a Python script, remember that behind the scenes, the PVM is working tirelessly to bring your code to life!</p><p>Did you find this explanation helpful? Let me know your thoughts in the comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2767bc2eb9d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>