<?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 Dan Walsh on Medium]]></title>
        <description><![CDATA[Stories by Dan Walsh on Medium]]></description>
        <link>https://medium.com/@danwalshnh?source=rss-14ee7ca49f6a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*5M4DTlBE_m1nhMLp</url>
            <title>Stories by Dan Walsh on Medium</title>
            <link>https://medium.com/@danwalshnh?source=rss-14ee7ca49f6a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 00:05:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@danwalshnh/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[Your first Python lesson should be this and involve Pokemon…]]></title>
            <link>https://medium.com/@danwalshnh/your-first-python-lesson-should-be-this-and-involve-pokemon-e273b994bd13?source=rss-14ee7ca49f6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e273b994bd13</guid>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[learning-to-code]]></category>
            <dc:creator><![CDATA[Dan Walsh]]></dc:creator>
            <pubDate>Mon, 21 Sep 2020 19:58:04 GMT</pubDate>
            <atom:updated>2020-09-27T19:16:16.388Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HOxU42xdYv4F15s2pxQmxQ.jpeg" /><figcaption>Searching for Pokemon in Moab, Utah.</figcaption></figure><p>I started learning Python about 4 years ago when I entered graduate school for my Master’s in Data Science. Learning to program has become easier and more accessible but after years of studying Python and various other languages, I can still say most courses and tutorials fall short of explaining the heart of any language in an intuitive way. This leaves the student with an abstract understanding where they are left to copy code without understanding what they are doing at a fundamental level.</p><p>I want to share an analogous understanding of Python and objected-oriented programming that helped me quickly improve my Python skills and it involves Pokemon! Before beginning, this lesson assumes you have Python installed with at least a console at your fingertips. With that out of the way, I’ve found most Python courses, books, or tutorials start with this syllabus:</p><ol><li>Variables</li><li>Lists, dictionaries, tuples</li><li>Conditionals</li><li>Loops</li><li>Functions</li><li>Classes</li></ol><p>This is where most Python tutorials in my opinion fall short as they skip over the essence of how Python fundamentally operates and that is as an object-oriented programming language. To incorporate this fundamental concept, I would make one addition to this list and it is what this tutorial covers. Since Python uses zero-based indexing, I would add the following to the beginning:</p><p><strong>0. Introduction to objects and classes</strong></p><p>To begin, everything in Python is an object. Ok but what does that mean to someone new to programming as this a vague and abstract concept? How can we visualize this? It is here I would introduce my favorite childhood video game, Pokemon (90’s Gameboy version). We are going to use Pokemon and pokeballs as our example to turn an abstract understanding of Python into a tangible example we can at least mentally see.</p><p>Imagine your computer’s random access memory (RAM), as a giant ball pit filled empty pokeballs waiting to be used to capture Pokemon, or in our case data. Here are two examples you can plug into your Python console:</p><pre>&gt;&gt;&gt;x = 3<br>&gt;&gt;&gt;x<br>3<br>&gt;&gt;&gt;pokeball = &#39;Charizard&#39;<br>&gt;&gt;&gt;pokeball<br>&#39;Charizard&#39;</pre><p>These are just two simple variables: x with the integer 3 and pokeball with the string Charizard. Imagine that you took two of those empty pokeballs from the ball pit (RAM) and then with a sharpie (aka your keyboard) wrote ‘x’ and ‘pokeball’ on them. You then opened each pokeball using the ‘=’ sign and placed or assigned the integer 3 and the string Charizard in them. Congratulations! You captured your first Pokemon, oops I mean Python object!</p><p>There are three commands I recommend you use moving forward in learning and using Python objects once you’ve captured them. These commands will allow you to crack open these pokeballs, oops I mean objects and see what’s inside them and their capabilities.</p><h3>type(): The type of Pokemon or type of object</h3><p>At a Python console, try the following command on the two variables we entered earlier:</p><pre>&gt;&gt;&gt;type(pokeball)</pre><pre>&lt;class &#39;str&#39;&gt;</pre><pre>&gt;&gt;&gt;type(x)</pre><pre>&lt;class &#39;int&#39;&gt;</pre><p>What we get from using type() is the type of Pokemon, oops I mean Python object. There are so many different types of Python objects just like there are different types of Pokemon (i.e. water, electric, fire types). In using the type() command we can understand at a high-level the type of Pokemon, oops I mean object of interest. Python is filled with different object types such as integers (int), strings (str), floats (float), DataFrames and many others. We can even write our own Pokemon types, oops I mean Python objects, using the <strong>class </strong>keyword. Although I don’t go into writing objects in depth here, you’ll find a taste of this at the end of the tutorial in the Bonus section.</p><h3>dir(): The powers and characteristics of a Pokemon or methods and attributes of an object</h3><p>Although we may understand that a Pokemon can be of an electric, fire, or some other type, we want to dig further and understand the powers and attributes of that Pokemon. We have a similar desire to do this in Python. What are the powers and characteristics, or in Python, the methods and attributes of an object? A method is a function or action that does something like a Pokemon’s firespin attack whereas an attribute is a piece of information like the name or height of the Pokemon. The dir() helps us to see a list of these methods and attributes. In your console, try the following command:</p><pre>&gt;&gt;&gt;dir(pokeball)<br>[&#39;__add__&#39;, &#39;__class__&#39;, &#39;__contains__&#39;, &#39;__delattr__&#39;, &#39;__dir__&#39;, &#39;__doc__&#39;, &#39;__eq__&#39;, &#39;__format__&#39;, &#39;__ge__&#39;, &#39;__getattribute__&#39;, &#39;__getitem__&#39;, &#39;__getnewargs__&#39;, &#39;__gt__&#39;, &#39;__hash__&#39;, &#39;__init__&#39;, &#39;__init_subclass__&#39;, &#39;__iter__&#39;, &#39;__le__&#39;, &#39;__len__&#39;, &#39;__lt__&#39;, &#39;__mod__&#39;, &#39;__mul__&#39;, &#39;__ne__&#39;, &#39;__new__&#39;, &#39;__reduce__&#39;, &#39;__reduce_ex__&#39;, &#39;__repr__&#39;, &#39;__rmod__&#39;, &#39;__rmul__&#39;, &#39;__setattr__&#39;, &#39;__sizeof__&#39;, &#39;__str__&#39;, &#39;__subclasshook__&#39;, &#39;capitalize&#39;, &#39;casefold&#39;, &#39;center&#39;, &#39;count&#39;, &#39;encode&#39;, &#39;endswith&#39;, &#39;expandtabs&#39;, &#39;find&#39;, &#39;format&#39;, &#39;format_map&#39;, &#39;index&#39;, &#39;isalnum&#39;, &#39;isalpha&#39;, &#39;isascii&#39;, &#39;isdecimal&#39;, &#39;isdigit&#39;, &#39;isidentifier&#39;, &#39;islower&#39;, &#39;isnumeric&#39;, &#39;isprintable&#39;, &#39;isspace&#39;, &#39;istitle&#39;, &#39;isupper&#39;, &#39;join&#39;, &#39;ljust&#39;, &#39;lower&#39;, &#39;lstrip&#39;, &#39;maketrans&#39;, &#39;partition&#39;, &#39;replace&#39;, &#39;rfind&#39;, &#39;rindex&#39;, &#39;rjust&#39;, &#39;rpartition&#39;, &#39;rsplit&#39;, &#39;rstrip&#39;, &#39;split&#39;, &#39;splitlines&#39;, &#39;startswith&#39;, &#39;strip&#39;, &#39;swapcase&#39;, &#39;title&#39;, &#39;translate&#39;, &#39;upper&#39;, &#39;zfill&#39;]</pre><p>Wow! Those are a lot of powers and characteristics, oops I mean methods and attributes! You’ll also see this is a Python list (also an object!) that you can access and manipulate. There are two visually distinct types you can see here: double underscore methods or “dunder” methods for short and methods without the double underscores (i.e. zfill). I won’t go into detail in this tutorial about the difference but you can access and utilize them similarly for the most part. If we want to access a Pokemon and its powers you press the button on the pokeball to let it out. To access a Python object’s methods and attributes, use the dot (“.”) notation after the variable name followed by the method name and () if it is a method/function or exclude () if it is an attribute. For example at your Python console enter the following command:</p><pre>&gt;&gt;&gt;pokeball.upper()<br>&#39;CHARIZARD&#39;</pre><p>You’ll see “Charizard” used its “upper” power to uppercase its itself. We can see this power in the methods list after calling “dir(pokeball)” from earlier. Ok, it is a lame power compared to fire spin attack but I promise you even cooler powers or methods the deeper you dive into Python. Go ahead and experiment with the other powers for a string type. Additionally, notice when you use dir() on different Python objects like dir(x) which was integer 3. You’ll see a different list of methods appear. Different Python objects or types much like different Pokemon have different methods or powers.</p><h3>help(): The Pokedex info of a Pokemon or info on a Python object</h3><p>Finally, the last core command I recommend beginners at least have in their Python learning toolbelt is the help() command. Just like you can use a Pokedex to look up the information on a particular Pokemon, using the help() command on a Python object will give you the documentation on that object at the most in-depth level. So at your Python console type in the following:</p><pre>&gt;&gt;&gt;help(pokeball)<br>No Python documentation found for &#39;Charizard&#39;.<br>Use help() to get the interactive help utility.<br>Use help(str) for help on the str class.</pre><p>For a str object you need to use help(str) not help(pokeball) but help does work on int (i.e. help(x)) and other objects. If we call help on str, you’ll see:</p><pre>&gt;&gt;&gt;help(str)<br>Help on class str in module builtins:<br><br>class str(object)<br> |  str(object=&#39;&#39;) -&gt; str<br> |  str(bytes_or_buffer[, encoding[, errors]]) -&gt; str<br> |  <br> |  Create a new string object from the given object. If encoding or<br> |  errors is specified, then the object must expose a data buffer<br> |  that will be decoded using the given encoding and error handler.<br> |  Otherwise, returns the result of object.__str__() (if defined)<br> |  or repr(object).<br> |  encoding defaults to sys.getdefaultencoding().<br> |  errors defaults to &#39;strict&#39;.<br>...</pre><p>Depending on what console or IDE you are using, you can scroll down further through the documentation to learn more about the object, its methods, and how to properly use it. All of this documentation can be read online rather than in the console either at docs.Python.org or the website for the particular library you are using (i.e. go to <a href="https://pandas.pydata.org/">pandas.pydata.org/</a> for pandas documentation). Notice the word “class” is used to define that Pokemon type, oops I mean Python object. This may be too much documentation to parse through and you may prefer to hone in on a particular power/method of interest. To do this, all you have to do is use the dot notation (“.”) within the help() command to crack open that pokeball, oops I mean Python object, as follows:</p><pre>&gt;&gt;&gt;help(str.upper)<br>Help on method_descriptor:<br><br>upper(self, /)<br>    Return a copy of the string converted to uppercase.</pre><p>And voila! You can see that the upper method just takes itself as an argument indicated by the (self) and returns a copy of the string converted to uppercase.</p><h3>Summary</h3><p>The purpose of this lesson was meant to help you achieve two things:</p><ol><li>At the heart of Python are objects and they are less abstract if we think of them as pokeballs with different Pokemon in them all having their own powers and characteristics. Python is an object-oriented programming language and this analogy and foundation will hopefully make understanding Python easier. Python objects are just tons of pokeballs with Pokemon in them that you can crack open and see what’s inside. You can even make your own!</li><li>With the basic foundational understanding of objects, you should learn to navigate and explore Python rather than memorize functions or copy code without at least trying to understand what you are copying. You don’t memorize all the items in a food store but knowing how to navigate the aisles, read the signs, push a shopping cart, and use the checkout are the key skills rather than memorize the location of each item. Navigating Python is similar and being able to use the type(), dir(), and help() commands will aid you in your Python progression.</li></ol><p>Finally, consistent use and experimentation of these techniques overtime will help you gain a deeper and less abstract understanding of Python. With this foundation, you can continue on the traditional learning path of using variables, lists, conditionals, loops, functions, etc. with the understanding that you are just manipulating pokeballs, oops I meant Python objects.</p><h3>Bonus</h3><p>So you know how to navigate, crack open, and understand pokeballs, oops I mean Python objects, but now you are hungry to take the next step. No, I don’t mean eat the Pokemon or objects! Let’s create <strong>instructions</strong> to make our own Pokemon, oops I did it again, Python objects. To do this we will use the <strong>class</strong> keyword to define a Pokemon object in Python and give it two powers that simply print the words “Attack!” and “Defend!”. In a Python IDE or console write the following and run it.</p><pre>class Pokemon():<br>    def attack(self):<br>        print(&#39;Attack!&#39;)<br>    def defend(self):<br>        print(&#39;Defend!&#39;)</pre><p>Now, we’ve just written instructions for our very own Python object! In your console go ahead and create a new instance of a Pokemon by typing the following:</p><pre>&gt;&gt;&gt; charizard = Pokemon()</pre><p>You just created an instance of a new Pokemon that has the attack and defend powers. Now go ahead and use your new Pokemon.</p><pre>&gt;&gt;&gt;charizard.attack()<br>Attack!<br>&gt;&gt;&gt;charizard.defend()<br>Defend!</pre><p>Congratulations! You just unleashed the powers of your very own Pokemon and Python object. Maybe it’s not the most exciting Pokemon but this is just a simple foundational example to get you started on your path towards unleashing the power of Python. If you ever find yourself not understanding a particular object, just crack it open using the three commands shown in this tutorial. Happy exploring!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e273b994bd13" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Letters from War: Quarantine — Day 19]]></title>
            <link>https://medium.com/@danwalshnh/letters-from-war-quarantine-day-19-24599022437b?source=rss-14ee7ca49f6a------2</link>
            <guid isPermaLink="false">https://medium.com/p/24599022437b</guid>
            <category><![CDATA[quarantine]]></category>
            <category><![CDATA[comedy]]></category>
            <category><![CDATA[humor]]></category>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[coronavirus]]></category>
            <dc:creator><![CDATA[Dan Walsh]]></dc:creator>
            <pubDate>Tue, 31 Mar 2020 13:45:59 GMT</pubDate>
            <atom:updated>2020-03-31T13:45:59.396Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kzt9UYP3gGbh9mqPWZdzkQ.jpeg" /></figure><h3>Day 19</h3><p>Dear Mother,</p><p>It’s Day 19 of the Quarantine and the struggle is real but my spirits remain high still during this war. Every morning it’s the standard granola mix with almond milk and coffee. If I’m lucky, I’ll have avocado toast but they go quickly during shopping day and it’s too risky to go out often. Toilet paper is running dangerously low. I’m scared because I don’t know what’s going to happen when I run out. But I stay home. Stay home they say. Save lives. After breakfast it’s straight to the front news headlines of the day. It has become so depressing that I go wash my hands just to feel an ounce of relief from anxiety.</p><p>It’s then time to join my squad on the Battlefield before working remotely. Usually, we’re sent to the front lines at Fortnite, Apex, or PUBG. But the battles at the Islands of Animal Crossing seem to be ramping up in the last week. The scars of battle have opened my eyes to the lives of my squad. I’m no longer the n00b I once was 3 weeks ago fiddling with his inventory and getting pwned by 12 year olds.</p><p>Private “Big Jim” Miller is a laid off Insurance broker from Vermont. His wife just had their first child, a boy.</p><p>Private Billy ‘the Bull’ Butch who did construction in Dallas now fights like many for his girlfriend whose a nurse. They just got a Chihuahua.</p><p>Private Tammy ‘Whammy’ Johnson one of the sharpest shooters I ever met is from Arizona. No one can match her with a rifle. She works at Sephora part time.</p><p>After a run, I’ll then hit the remote work. Things are so blurry these days I don’t even know what day it is anymore. I’ve given up dressing the upper half of my body for Zoom calls. I don’t even use camera mode anymore. Just audio. I get the job done though and carry on. We all must carry on.</p><p>By end of day, I realize the lethargy hits hard so I stretch and do some yoga before heading back out to battle with the Squad. We lost Big Jim yesterday to a slow internet connection. I won’t forget his last words…”Keep advancing.” Words we must all live by.</p><p>Dinner time is usually some pasta after the 6 o’clock daily reports. If I’m lucky I’ll get a lone walk around the block. But I keep my distance from everyone because you don’t know who is hiding the enemy.</p><p>Before bed, I remember to watch my daily Netflix. You can always find something to satisfy the soul. Then it’s off to bed and I’ve done my duty for the day.</p><p>I do this for the healthcare workers, the grocery store clerks, and the other essential soldiers in this war. I do this so I can hug you and see everyone again. Brighter days are ahead and we will win this war. Until then…</p><p>With love,</p><p>Johnny Privilege<br>Private Non Essential 1st Class<br>United States Fortnite Squad</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24599022437b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>