<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: Write Unbreakable Python	</title>
	<atom:link href="https://jessewarden.com/2020/03/write-unbreakable-python.html/feed" rel="self" type="application/rss+xml" />
	<link>https://jessewarden.com/2020/03/write-unbreakable-python.html</link>
	<description>Software &#124; Fitness &#124; Gaming</description>
	<lastBuildDate>Sun, 12 Jul 2020 03:32:53 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>
		By: JesterXL		</title>
		<link>https://jessewarden.com/2020/03/write-unbreakable-python.html/comment-page-1#comment-253521</link>

		<dc:creator><![CDATA[JesterXL]]></dc:creator>
		<pubDate>Sun, 12 Jul 2020 03:32:53 +0000</pubDate>
		<guid isPermaLink="false">https://jessewarden.com/?p=5890#comment-253521</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://jessewarden.com/2020/03/write-unbreakable-python.html/comment-page-1#comment-253135&quot;&gt;Paul&lt;/a&gt;.

Probably a mess up on my part. Normally in PyDash, &lt;a href=&quot;https://pydash.readthedocs.io/en/latest/api.html#pydash.arrays.nth&quot; rel=&quot;nofollow ugc&quot;&gt;nth&lt;/a&gt; will return a &lt;code&gt;None&lt;/code&gt; or your value. However, that&#039;s not really helpful so we &quot;lift&quot; as they call it to a &lt;code&gt;Maybe&lt;/code&gt;. I&#039;ll check that section again, thanks for letting me know. In the meantime, just know that &lt;code&gt;nth&lt;/code&gt; is a pure function and won&#039;t blow up, whereas in normal Python code, accessing a List with an index that doesn&#039;t exist results in an Exception. Using &lt;code&gt;nth&lt;/code&gt; is safe, but downstream code may not be expecting a &lt;code&gt;None&lt;/code&gt; and end up throwing an Exception by accident. Forcing it to be a &lt;code&gt;Maybe&lt;/code&gt; ensures the downstream is then forced to handle the &lt;code&gt;Nothing&lt;/code&gt; scenario.

Using the &lt;a href=&quot;https://returns.readthedocs.io/en/latest/pages/maybe.html&quot; rel=&quot;nofollow ugc&quot;&gt;returns library&lt;/a&gt;, they have a wonderful decorator to make this easier:

&lt;pre&gt;&lt;code&gt;
@maybe
def safe_nth(index, list):
  return nth(index, list)
&lt;/code&gt;&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://jessewarden.com/2020/03/write-unbreakable-python.html/comment-page-1#comment-253135">Paul</a>.</p>
<p>Probably a mess up on my part. Normally in PyDash, <a href="https://pydash.readthedocs.io/en/latest/api.html#pydash.arrays.nth" rel="nofollow ugc">nth</a> will return a <code>None</code> or your value. However, that&#8217;s not really helpful so we &#8220;lift&#8221; as they call it to a <code>Maybe</code>. I&#8217;ll check that section again, thanks for letting me know. In the meantime, just know that <code>nth</code> is a pure function and won&#8217;t blow up, whereas in normal Python code, accessing a List with an index that doesn&#8217;t exist results in an Exception. Using <code>nth</code> is safe, but downstream code may not be expecting a <code>None</code> and end up throwing an Exception by accident. Forcing it to be a <code>Maybe</code> ensures the downstream is then forced to handle the <code>Nothing</code> scenario.</p>
<p>Using the <a href="https://returns.readthedocs.io/en/latest/pages/maybe.html" rel="nofollow ugc">returns library</a>, they have a wonderful decorator to make this easier:</p>
<pre><code>
@maybe
def safe_nth(index, list):
  return nth(index, list)
</code></pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Paul		</title>
		<link>https://jessewarden.com/2020/03/write-unbreakable-python.html/comment-page-1#comment-253135</link>

		<dc:creator><![CDATA[Paul]]></dc:creator>
		<pubDate>Mon, 18 May 2020 16:09:36 +0000</pubDate>
		<guid isPermaLink="false">https://jessewarden.com/?p=5890#comment-253135</guid>

					<description><![CDATA[Thanks for making such a thorough post about this. As a full-time Python engineer and an FP enthusiast (and having noticed Rust&#039;s Option and Result types)  I&#039;m definitely in the target audience.

One example that I didn&#039;t quite get was the one below &quot;You’ll see this implemented in a more re-usable way as nth, except instead of returning None, it’ll return a Maybe&quot; -- it returns the same things as the previous example (modulo capitalization on &quot;OK/Ok&quot;). Is there some other code that&#039;s supposed to be there?]]></description>
			<content:encoded><![CDATA[<p>Thanks for making such a thorough post about this. As a full-time Python engineer and an FP enthusiast (and having noticed Rust&#8217;s Option and Result types)  I&#8217;m definitely in the target audience.</p>
<p>One example that I didn&#8217;t quite get was the one below &#8220;You’ll see this implemented in a more re-usable way as nth, except instead of returning None, it’ll return a Maybe&#8221; &#8212; it returns the same things as the previous example (modulo capitalization on &#8220;OK/Ok&#8221;). Is there some other code that&#8217;s supposed to be there?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Geoff Ford		</title>
		<link>https://jessewarden.com/2020/03/write-unbreakable-python.html/comment-page-1#comment-252822</link>

		<dc:creator><![CDATA[Geoff Ford]]></dc:creator>
		<pubDate>Sat, 04 Apr 2020 06:59:29 +0000</pubDate>
		<guid isPermaLink="false">https://jessewarden.com/?p=5890#comment-252822</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://jessewarden.com/2020/03/write-unbreakable-python.html/comment-page-1#comment-252804&quot;&gt;JesterXL&lt;/a&gt;.

Good point and that other article is a great read as well...]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://jessewarden.com/2020/03/write-unbreakable-python.html/comment-page-1#comment-252804">JesterXL</a>.</p>
<p>Good point and that other article is a great read as well&#8230;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: JesterXL		</title>
		<link>https://jessewarden.com/2020/03/write-unbreakable-python.html/comment-page-1#comment-252810</link>

		<dc:creator><![CDATA[JesterXL]]></dc:creator>
		<pubDate>Tue, 31 Mar 2020 02:16:19 +0000</pubDate>
		<guid isPermaLink="false">https://jessewarden.com/?p=5890#comment-252810</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://jessewarden.com/2020/03/write-unbreakable-python.html/comment-page-1#comment-252809&quot;&gt;Laurent&lt;/a&gt;.

&#039;Cause I stupid and don&#039;t proof read. Thanks for the catch! It should be:

&lt;pre&gt;&lt;code&gt;def get_loan_ids_result():
  return get_kms_secret() \
  &gt;&gt; get_oauth_token \
  &gt;&gt; get_loan_ids&lt;/code&gt;&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://jessewarden.com/2020/03/write-unbreakable-python.html/comment-page-1#comment-252809">Laurent</a>.</p>
<p>&#8216;Cause I stupid and don&#8217;t proof read. Thanks for the catch! It should be:</p>
<pre><code>def get_loan_ids_result():
  return get_kms_secret() \
  >> get_oauth_token \
  >> get_loan_ids</code></pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Laurent		</title>
		<link>https://jessewarden.com/2020/03/write-unbreakable-python.html/comment-page-1#comment-252809</link>

		<dc:creator><![CDATA[Laurent]]></dc:creator>
		<pubDate>Mon, 30 Mar 2020 08:43:37 +0000</pubDate>
		<guid isPermaLink="false">https://jessewarden.com/?p=5890#comment-252809</guid>

					<description><![CDATA[Nice explanations. I may give it a try at some point.
Isn&#039;t there a typo around get_loan_ids? &quot;def get_loan_ids()&quot; seems to call an overloaded version of itself with &quot;&#062;&#062; get_loan_ids&quot;. Since we cannot overload functions in Python how do you make get_loan_ids() coexist with get_loan_ids(token).]]></description>
			<content:encoded><![CDATA[<p>Nice explanations. I may give it a try at some point.<br />
Isn&#8217;t there a typo around get_loan_ids? &#8220;def get_loan_ids()&#8221; seems to call an overloaded version of itself with &#8220;&gt;&gt; get_loan_ids&#8221;. Since we cannot overload functions in Python how do you make get_loan_ids() coexist with get_loan_ids(token).</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
