Skip to content

Commit 12ba20d

Browse files
author
Exploding Labs Bot
committed
Update site from Jekyll source repo
1 parent 3a09556 commit 12ba20d

File tree

92 files changed

+709
-1094
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+709
-1094
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<div class="wide-logos">
2+
<p><img src="/posts/assets/python.png" alt="python" /></p>
3+
</div>
4+
5+
<div id="intro">
6+
<p>We have a dictionary, and want to convert it to a an object with postfix
7+
notation like <code class="language-plaintext highlighter-rouge">obj.name</code>.</p>
8+
</div>
9+
10+
<h2 id="convert-to-an-immutable-object">Convert to an immutable object</h2>
11+
12+
<p>Use <code class="language-plaintext highlighter-rouge">collections.namedtuple</code>.</p>
13+
14+
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">&gt;&gt;&gt;</span> <span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">namedtuple</span>
15+
<span class="o">&gt;&gt;&gt;</span> <span class="n">data</span> <span class="o">=</span> <span class="p">{</span><span class="s">"id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"name"</span><span class="p">:</span> <span class="s">"foo"</span><span class="p">}</span>
16+
<span class="o">&gt;&gt;&gt;</span> <span class="n">namedtuple</span><span class="p">(</span><span class="s">"Obj"</span><span class="p">,</span> <span class="n">data</span><span class="p">.</span><span class="n">keys</span><span class="p">())(</span><span class="o">**</span><span class="n">data</span><span class="p">)</span>
17+
<span class="n">Obj</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">'foo'</span><span class="p">)</span>
18+
</code></pre></div></div>
19+
20+
<h2 id="convert-to-a-mutable-object">Convert to a mutable object</h2>
21+
22+
<p>Use <code class="language-plaintext highlighter-rouge">types.SimpleNamespace</code>.</p>
23+
24+
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">&gt;&gt;&gt;</span> <span class="kn">from</span> <span class="nn">types</span> <span class="kn">import</span> <span class="n">SimpleNamespace</span>
25+
<span class="o">&gt;&gt;&gt;</span> <span class="n">SimpleNamespace</span><span class="p">(</span><span class="o">**</span><span class="p">{</span><span class="s">"id"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s">"name"</span><span class="p">:</span> <span class="s">"foo"</span><span class="p">})</span>
26+
<span class="n">namespace</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s">"foo"</span><span class="p">)</span>
27+
</code></pre></div></div>
28+
29+
<p>See also: <a href="/convert-sequence-to-postfix-notation">Convert a sequence to postfix notation</a></p>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<div class="wide-logos">
2+
<p><img src="/posts/assets/python.png" alt="python" /></p>
3+
</div>
4+
5+
<div id="intro">
6+
<p>We have a sequence such as a tuple or list, and want to convert it to a an
7+
object with named attributes in postfix notation (‘obj.name’).</p>
8+
</div>
9+
10+
<h2 id="convert-to-an-immutable-object">Convert to an immutable object</h2>
11+
12+
<p>Use <code class="language-plaintext highlighter-rouge">collections.namedtuple</code>.</p>
13+
14+
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">&gt;&gt;&gt;</span> <span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">namedtuple</span>
15+
<span class="o">&gt;&gt;&gt;</span> <span class="n">data</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="s">'foo'</span><span class="p">)</span>
16+
<span class="o">&gt;&gt;&gt;</span> <span class="n">obj</span> <span class="o">=</span> <span class="n">namedtuple</span><span class="p">(</span><span class="s">'Obj'</span><span class="p">,</span> <span class="p">[</span><span class="s">'id'</span><span class="p">,</span> <span class="s">'name'</span><span class="p">])(</span><span class="o">*</span><span class="n">data</span><span class="p">)</span>
17+
<span class="o">&gt;&gt;&gt;</span> <span class="n">obj</span><span class="p">.</span><span class="n">name</span>
18+
<span class="s">'foo'</span>
19+
</code></pre></div></div>
20+
21+
<h2 id="convert-to-a-mutable-object">Convert to a mutable object</h2>
22+
23+
<p>Use <code class="language-plaintext highlighter-rouge">types.SimpleNamespace</code>.</p>
24+
25+
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">&gt;&gt;&gt;</span> <span class="kn">from</span> <span class="nn">types</span> <span class="kn">import</span> <span class="n">SimpleNamespace</span>
26+
<span class="o">&gt;&gt;&gt;</span> <span class="n">data</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="s">'foo'</span><span class="p">)</span>
27+
<span class="o">&gt;&gt;&gt;</span> <span class="n">obj</span> <span class="o">=</span> <span class="n">SimpleNamespace</span><span class="p">(</span><span class="o">**</span><span class="nb">dict</span><span class="p">(</span><span class="nb">zip</span><span class="p">([</span><span class="s">'id'</span><span class="p">,</span> <span class="s">'name'</span><span class="p">],</span> <span class="n">data</span><span class="p">)))</span>
28+
<span class="o">&gt;&gt;&gt;</span> <span class="n">obj</span><span class="p">.</span><span class="n">name</span>
29+
<span class="s">'foo'</span>
30+
</code></pre></div></div>
31+
32+
<p>See also: <a href="/python/convert-dict-to-postfix-notation">Convert a dictionary to postfix notation</a></p>
Lines changed: 6 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,18 @@
1-
<!DOCTYPE html>
2-
<html>
3-
<head>
4-
5-
6-
<meta charset="utf-8">
7-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
8-
<meta name="viewport" content="width=device-width, initial-scale=1">
9-
10-
<meta property="og:title" content="How to use Readline in the Python REPL on MacOS?" />
11-
<meta property="og:type" content="website" />
12-
<meta property="og:url" content="https://www.explodinglabs.com/posts/" />
13-
<meta property="og:image" content="https://www.explodinglabs.com/posts/assets/opengraph.png" />
14-
<meta property="og:image:secure_url" content="https://www.explodinglabs.com/posts/assets/opengraph.png" />
15-
<meta property="og:image:type" content="image/png" />
16-
<meta property="og:image:width" content="1200" />
17-
<meta property="og:image:height" content="630" />
18-
<meta property="og:image:alt" content="Composition in architecture" />
19-
20-
<link rel="stylesheet" href="/posts/main.css">
21-
<link rel="alternate" type="application/rss+xml" title="Exploding Labs Blog" href="https://explodinglabs.com/posts/feed.xml">
22-
<link rel="author" href="https://plus.google.com/u/0/110235318020270619650?rel=author" />
23-
24-
<link rel="icon" type="image/png" href="/assets/favicon-16x16.png?v=2" sizes="16x16">
25-
<link rel="icon" type="image/png" href="/assets/favicon-32x32.png?v=2" sizes="32x32">
26-
<link rel="icon" type="image/png" href="/assets/favicon-96x96.png?v=2" sizes="96x96">
27-
28-
<link rel="apple-touch-icon" sizes="120x120" href="/assets/apple-touch-icon-120x120.png?v=2">
29-
<link rel="apple-touch-icon" sizes="152x152" href="/assets/apple-touch-icon-152x152.png?v=2">
30-
<link rel="apple-touch-icon" sizes="167x167" href="/assets/apple-touch-icon-167x167.png?v=2">
31-
<link rel="apple-touch-icon" sizes="180x180" href="/assets/apple-touch-icon-180x180.png?v=2">
32-
33-
34-
35-
<!-- Begin Jekyll SEO tag v2.7.1 -->
36-
<title>How to use Readline in the Python REPL on MacOS? | Exploding Labs Blog</title>
37-
<meta name="generator" content="Jekyll v4.2.0" />
38-
<meta property="og:title" content="How to use Readline in the Python REPL on MacOS?" />
39-
<meta name="author" content="Beau Barker" />
40-
<meta property="og:locale" content="en_AU" />
41-
<meta name="description" content="A programming blog." />
42-
<meta property="og:description" content="A programming blog." />
43-
<link rel="canonical" href="https://explodinglabs.com/posts/python/mac-repl-readline" />
44-
<meta property="og:url" content="https://explodinglabs.com/posts/python/mac-repl-readline" />
45-
<meta property="og:site_name" content="Exploding Labs Blog" />
46-
<meta property="og:image" content="https://explodinglabs.com/posts/assets/python-wide.png" />
47-
<meta property="og:type" content="article" />
48-
<meta property="article:published_time" content="2018-06-20T00:00:00+00:00" />
49-
<meta name="twitter:card" content="summary_large_image" />
50-
<meta property="twitter:image" content="https://explodinglabs.com/posts/assets/python-wide.png" />
51-
<meta property="twitter:title" content="How to use Readline in the Python REPL on MacOS?" />
52-
<script type="application/ld+json">
53-
{"description":"A programming blog.","mainEntityOfPage":{"@type":"WebPage","@id":"https://explodinglabs.com/posts/python/mac-repl-readline"},"image":"https://explodinglabs.com/posts/assets/python-wide.png","headline":"How to use Readline in the Python REPL on MacOS?","dateModified":"2025-07-15T23:16:53+00:00","datePublished":"2018-06-20T00:00:00+00:00","url":"https://explodinglabs.com/posts/python/mac-repl-readline","author":{"@type":"Person","name":"Beau Barker"},"@type":"BlogPosting","@context":"https://schema.org"}</script>
54-
<!-- End Jekyll SEO tag -->
55-
56-
</head>
57-
<body>
58-
59-
60-
61-
62-
<nav>
63-
<div id="logo">
64-
<a href="/posts/">Exploding Labs Posts<!--img src="/posts/assets/composed.png" /--></a>
65-
</div>
66-
<div id="categories">
67-
<!--a href="/posts/">All</a>
68-
<span>(73)</span-->
69-
70-
<a href="/posts/haskell/">Haskell</a>
71-
<span>(2)</span>
72-
73-
<a href="/posts/jsonrpc/">JSON-RPC</a>
74-
<span>(16)</span>
75-
76-
<a href="/posts/python/">Python</a>
77-
<span>(19)</span>
78-
79-
<a href="/posts/airflow/">Airflow</a>
80-
<span>(6)</span>
81-
</div>
82-
</nav>
83-
84-
<main>
85-
86-
<article itemscope itemtype="http://schema.org/BlogPosting">
87-
<header>
88-
<h1>How to use Readline in the Python REPL on MacOS?</h1>
89-
<div class="post-meta">
90-
<time datetime="2018-06-20T00:00:00+00:00" itemprop="datePublished">
91-
Beau Barker, <time>Jun 20, 2018</time>.
92-
93-
Updated <time>Jul 15, 2025</time>.
94-
95-
<a href="https://github.com/explodinglabs/posts/edit/main/docs/_posts/python/2018-06-20-mac-repl-readline.markdown">
96-
&#9998;
97-
</a>
98-
</time>
99-
</div>
100-
</header>
101-
<div class="wide-logos">
102-
<p><img src="/assets/python.png" alt="python" /></p>
1+
<div class="wide-logos">
2+
<p><img src="/posts/assets/python.png" alt="python" /></p>
1033
</div>
1044

1055
<div id="intro">
1066
<p>How to use readline in the Python interactive interpreter on Mac.</p>
1077
</div>
1088

1099
<p>Install the gnureadline Python package:</p>
10+
11011
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code>pip <span class="nb">install </span>gnureadline
11112
</code></pre></div></div>
11213

11314
<p>Create a <code class="language-plaintext highlighter-rouge">~/.pythonstartup.py</code> script:</p>
15+
11416
<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">atexit</span>
11517
<span class="kn">import</span> <span class="nn">gnureadline</span> <span class="k">as</span> <span class="n">readline</span>
11618
<span class="kn">import</span> <span class="nn">logging</span>
@@ -142,26 +44,16 @@ <h1>How to use Readline in the Python REPL on MacOS?</h1>
14244
</code></pre></div></div>
14345

14446
<p>Set the <code class="language-plaintext highlighter-rouge">PYTHONSTARTUP</code> env var:</p>
47+
14548
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">export </span><span class="nv">PYTHONSTARTUP</span><span class="o">=</span><span class="nv">$HOME</span>/.pythonstartup.py
14649
</code></pre></div></div>
14750

14851
<p>Start the Python REPL.</p>
52+
14953
<div class="language-sh highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nv">$ </span>python
15054
Python 3.6.5 <span class="o">(</span>default, Mar 29 2018, 15:37:32<span class="o">)</span>
15155
<span class="o">[</span>GCC 4.2.1 Compatible Apple LLVM 9.0.0 <span class="o">(</span>clang-900.0.39.2<span class="o">)]</span> on darwin
15256
Type <span class="s2">"help"</span>, <span class="s2">"copyright"</span>, <span class="s2">"credits"</span> or <span class="s2">"license"</span> <span class="k">for </span>more information.
15357
Booted pythonstartup.py.
15458
<span class="o">&gt;&gt;&gt;</span>
15559
</code></pre></div></div>
156-
157-
<footer>
158-
<a href="/python">More Python posts</a>
159-
</footer>
160-
</article>
161-
162-
163-
164-
</main>
165-
166-
</body>
167-
</html>

posts/airflow/execute-context.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<meta property="twitter:image" content="https://explodinglabs.com/posts/assets/airflow-wide.png" />
5151
<meta property="twitter:title" content="What’s in Airflow’s context dictionary?" />
5252
<script type="application/ld+json">
53-
{"description":"Showing the contents of the “context” object, which is available in an Operator’s execute method, or a PythonOperator’s function definition.","mainEntityOfPage":{"@type":"WebPage","@id":"https://explodinglabs.com/posts/airflow/execute-context"},"image":"https://explodinglabs.com/posts/assets/airflow-wide.png","headline":"What’s in Airflow’s context dictionary?","dateModified":"2025-07-15T23:16:53+00:00","datePublished":"2017-12-13T00:00:00+00:00","url":"https://explodinglabs.com/posts/airflow/execute-context","author":{"@type":"Person","name":"Beau Barker"},"@type":"BlogPosting","@context":"https://schema.org"}</script>
53+
{"description":"Showing the contents of the “context” object, which is available in an Operator’s execute method, or a PythonOperator’s function definition.","mainEntityOfPage":{"@type":"WebPage","@id":"https://explodinglabs.com/posts/airflow/execute-context"},"image":"https://explodinglabs.com/posts/assets/airflow-wide.png","headline":"What’s in Airflow’s context dictionary?","dateModified":"2025-07-15T23:32:02+00:00","datePublished":"2017-12-13T00:00:00+00:00","url":"https://explodinglabs.com/posts/airflow/execute-context","author":{"@type":"Person","name":"Beau Barker"},"@type":"BlogPosting","@context":"https://schema.org"}</script>
5454
<!-- End Jekyll SEO tag -->
5555

5656
</head>
@@ -61,11 +61,11 @@
6161

6262
<nav>
6363
<div id="logo">
64-
<a href="/posts/">Exploding Labs Posts<!--img src="/posts/assets/composed.png" /--></a>
64+
<a href="https://www.explodinglabs.com/">Exploding Labs</a>
6565
</div>
6666
<div id="categories">
67-
<!--a href="/posts/">All</a>
68-
<span>(73)</span-->
67+
<a href="/posts/">Posts</a>
68+
<span>(73)</span>
6969

7070
<a href="/posts/haskell/">Haskell</a>
7171
<span>(2)</span>
@@ -74,7 +74,7 @@
7474
<span>(16)</span>
7575

7676
<a href="/posts/python/">Python</a>
77-
<span>(19)</span>
77+
<span>(16)</span>
7878

7979
<a href="/posts/airflow/">Airflow</a>
8080
<span>(6)</span>

posts/airflow/fernet-key.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
<meta property="twitter:image" content="https://explodinglabs.com/posts/assets/airflow-wide.png" />
5151
<meta property="twitter:title" content="How to generate a Fernet key?" />
5252
<script type="application/ld+json">
53-
{"description":"How to create a fernet key which is required for storing encrypted passwords.","mainEntityOfPage":{"@type":"WebPage","@id":"https://explodinglabs.com/posts/airflow/fernet-key"},"image":"https://explodinglabs.com/posts/assets/airflow-wide.png","headline":"How to generate a Fernet key?","dateModified":"2025-07-15T23:16:53+00:00","datePublished":"2018-01-12T00:00:00+00:00","url":"https://explodinglabs.com/posts/airflow/fernet-key","author":{"@type":"Person","name":"Beau Barker"},"@type":"BlogPosting","@context":"https://schema.org"}</script>
53+
{"description":"How to create a fernet key which is required for storing encrypted passwords.","mainEntityOfPage":{"@type":"WebPage","@id":"https://explodinglabs.com/posts/airflow/fernet-key"},"image":"https://explodinglabs.com/posts/assets/airflow-wide.png","headline":"How to generate a Fernet key?","dateModified":"2025-07-15T23:32:02+00:00","datePublished":"2018-01-12T00:00:00+00:00","url":"https://explodinglabs.com/posts/airflow/fernet-key","author":{"@type":"Person","name":"Beau Barker"},"@type":"BlogPosting","@context":"https://schema.org"}</script>
5454
<!-- End Jekyll SEO tag -->
5555

5656
</head>
@@ -61,11 +61,11 @@
6161

6262
<nav>
6363
<div id="logo">
64-
<a href="/posts/">Exploding Labs Posts<!--img src="/posts/assets/composed.png" /--></a>
64+
<a href="https://www.explodinglabs.com/">Exploding Labs</a>
6565
</div>
6666
<div id="categories">
67-
<!--a href="/posts/">All</a>
68-
<span>(73)</span-->
67+
<a href="/posts/">Posts</a>
68+
<span>(73)</span>
6969

7070
<a href="/posts/haskell/">Haskell</a>
7171
<span>(2)</span>
@@ -74,7 +74,7 @@
7474
<span>(16)</span>
7575

7676
<a href="/posts/python/">Python</a>
77-
<span>(19)</span>
77+
<span>(16)</span>
7878

7979
<a href="/posts/airflow/">Airflow</a>
8080
<span>(6)</span>

posts/airflow/gpl-dependency-error-with-pip.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<meta name="twitter:card" content="summary" />
4949
<meta property="twitter:title" content="GPL dependency error installing Airflow 1.10" />
5050
<script type="application/ld+json">
51-
{"description":"A programming blog.","mainEntityOfPage":{"@type":"WebPage","@id":"https://explodinglabs.com/posts/airflow/gpl-dependency-error-with-pip"},"headline":"GPL dependency error installing Airflow 1.10","dateModified":"2025-07-15T23:16:53+00:00","datePublished":"2018-08-28T00:00:00+00:00","url":"https://explodinglabs.com/posts/airflow/gpl-dependency-error-with-pip","author":{"@type":"Person","name":"Beau Barker"},"@type":"BlogPosting","@context":"https://schema.org"}</script>
51+
{"description":"A programming blog.","mainEntityOfPage":{"@type":"WebPage","@id":"https://explodinglabs.com/posts/airflow/gpl-dependency-error-with-pip"},"headline":"GPL dependency error installing Airflow 1.10","dateModified":"2025-07-15T23:32:02+00:00","datePublished":"2018-08-28T00:00:00+00:00","url":"https://explodinglabs.com/posts/airflow/gpl-dependency-error-with-pip","author":{"@type":"Person","name":"Beau Barker"},"@type":"BlogPosting","@context":"https://schema.org"}</script>
5252
<!-- End Jekyll SEO tag -->
5353

5454
</head>
@@ -59,11 +59,11 @@
5959

6060
<nav>
6161
<div id="logo">
62-
<a href="/posts/">Exploding Labs Posts<!--img src="/posts/assets/composed.png" /--></a>
62+
<a href="https://www.explodinglabs.com/">Exploding Labs</a>
6363
</div>
6464
<div id="categories">
65-
<!--a href="/posts/">All</a>
66-
<span>(73)</span-->
65+
<a href="/posts/">Posts</a>
66+
<span>(73)</span>
6767

6868
<a href="/posts/haskell/">Haskell</a>
6969
<span>(2)</span>
@@ -72,7 +72,7 @@
7272
<span>(16)</span>
7373

7474
<a href="/posts/python/">Python</a>
75-
<span>(19)</span>
75+
<span>(16)</span>
7676

7777
<a href="/posts/airflow/">Airflow</a>
7878
<span>(6)</span>

0 commit comments

Comments
 (0)