<?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:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[blog.juzten.com]]></title><description><![CDATA[Tech thoughts, stories, ideas, and tons of python]]></description><link>http://blog.juzten.com/</link><image><url>http://blog.juzten.com/favicon.png</url><title>blog.juzten.com</title><link>http://blog.juzten.com/</link></image><generator>Ghost 5.2</generator><lastBuildDate>Wed, 04 Mar 2026 09:34:10 GMT</lastBuildDate><atom:link href="http://blog.juzten.com/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Python Keyword-only arguments]]></title><description><![CDATA[<p><a href="https://peps.python.org/pep-3102/">PEP 3102</a> introduced keyword-only arguments which enforce specific function arguments to be supplied by a keyword. </p><p>By placing an asterisk <code>*</code> as the first function argument, we&apos;re telling python that all of the following arguments are required to use their keyword when calling the function. </p><p>The keyword arguments can</p>]]></description><link>http://blog.juzten.com/python-keyword/</link><guid isPermaLink="false">637efc205ca3b5243331e891</guid><category><![CDATA[python]]></category><dc:creator><![CDATA[juzten]]></dc:creator><pubDate>Thu, 24 Nov 2022 06:03:28 GMT</pubDate><media:content url="https://images.unsplash.com/photo-1603880921125-88ce2fc04673?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=MnwxMTc3M3wwfDF8c2VhcmNofDJ8fG9yZGVyfGVufDB8fHx8MTY2OTI2OTg0Ng&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=2000" medium="image"/><content:encoded><![CDATA[<img src="https://images.unsplash.com/photo-1603880921125-88ce2fc04673?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=MnwxMTc3M3wwfDF8c2VhcmNofDJ8fG9yZGVyfGVufDB8fHx8MTY2OTI2OTg0Ng&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=2000" alt="Python Keyword-only arguments"><p><a href="https://peps.python.org/pep-3102/">PEP 3102</a> introduced keyword-only arguments which enforce specific function arguments to be supplied by a keyword. </p><p>By placing an asterisk <code>*</code> as the first function argument, we&apos;re telling python that all of the following arguments are required to use their keyword when calling the function. </p><p>The keyword arguments can also be passed in any order when using the function. </p><pre><code class="language-python">def calculate_tax(*, before_tax_price, sales_tax_percent, discount_in_dollars):
    &quot;&quot;&quot;Calculate sales tax after removing discount&quot;&quot;&quot;
    discounted_price = before_tax_price - discount_in_dollars
    return (sales_tax_percent / 100) * discounted_price 


calculate_tax(before_tax_price=200, sales_tax_percent=6.5, discount_in_dollars=15)
&gt;&gt;&gt; 12.025

// different order
calculate_tax(before_tax_price=200, discount_in_dollars=15, sales_tax_percent=6.5)
&gt;&gt;&gt; 12.025</code></pre><p>If we don&apos;t pass in the keywords to the function when using it we get a <code>TypeError </code> error saying the function takes 0 positional arguments.</p><pre><code class="language-python">calculate_tax(before_tax_price=200, sales_tax_percent=6.5, 15)

TypeError: calculate_tax() takes 0 positional arguments but 3 were given</code></pre><p>When using this keyword-only argument syntax, we can be sure that anyone that uses this function must always use the arguments by their name which enforces a little safety. If we didn&apos;t use the keyword-only argument syntax, we could accidentally pass in parameters in the wrong order to the function which could lead to a bug. </p><pre><code class="language-python">def calculate_tax(before_tax_price, sales_tax_percent, discount_in_dollars):
    &quot;&quot;&quot;Calculate sales tax after removing discount&quot;&quot;&quot;
    discounted_price = before_tax_price - discount_in_dollars
    return (sales_tax_percent / 100) * discounted_price


calculate_tax(200, 6.5, 15)
&gt;&gt;&gt; 12.025 // correct


calculate_tax(200, 15, 6.5) // passing the arguments in the wrong order
&gt;&gt;&gt; 29.025 // incorrect</code></pre>]]></content:encoded></item><item><title><![CDATA[Git Cherry Pick]]></title><description><![CDATA[<p>Git makes it easy to pull in commits from different branches, lets&apos;s say we want to pull in a specific commit from <code>awesome-branch</code> into our current working branch named <code>current-branch</code>. If the commit we want to pull in is behind a few other commits that we don&apos;</p>]]></description><link>http://blog.juzten.com/git-cherry-pick/</link><guid isPermaLink="false">62b533555ca3b5243331e7f6</guid><dc:creator><![CDATA[juzten]]></dc:creator><pubDate>Thu, 07 Jul 2022 05:56:29 GMT</pubDate><media:content url="https://images.unsplash.com/photo-1551207195-3e4d6ccafe7b?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=MnwxMTc3M3wwfDF8c2VhcmNofDE4fHxjaGVycnl8ZW58MHx8fHwxNjU3MTczMzA2&amp;ixlib=rb-1.2.1&amp;q=80&amp;w=2000" medium="image"/><content:encoded><![CDATA[<img src="https://images.unsplash.com/photo-1551207195-3e4d6ccafe7b?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=MnwxMTc3M3wwfDF8c2VhcmNofDE4fHxjaGVycnl8ZW58MHx8fHwxNjU3MTczMzA2&amp;ixlib=rb-1.2.1&amp;q=80&amp;w=2000" alt="Git Cherry Pick"><p>Git makes it easy to pull in commits from different branches, lets&apos;s say we want to pull in a specific commit from <code>awesome-branch</code> into our current working branch named <code>current-branch</code>. If the commit we want to pull in is behind a few other commits that we don&apos;t need, we can use<code>git cherry-pick</code> to pull in the single commit we need. </p><p>tl;dr - how do I get a single commit from one branch into another branch</p><ol><li>Identify the commit hash from the commit you want to pull in from <code>awesome-branch</code>, lets&apos;s call this commit has <code>12345</code> </li><li>While the <code>current-branch</code> is checked out, run <code>git cherry-pick 12345</code></li></ol><p>That&apos;s it!</p><p>We can also pull in a series of commits using cherry-pick</p><p><strong>Cherry pick multiple commits</strong></p><p><code>git cherry-pick 12345 67890</code></p><p><strong>Cherry pick a range of commits</strong></p><p><code>git cherry-pick 1^..8</code></p>]]></content:encoded></item><item><title><![CDATA[Do It Anyways]]></title><description><![CDATA[<p>So you have a really cool idea for an app, game, or solution to a problem. You get super pumped about it and start researching your idea, then the unexpected happens. You find out that somebody else has came up with the same idea and they have already produced it.</p>]]></description><link>http://blog.juzten.com/do-it-anyways/</link><guid isPermaLink="false">62b52c745ca3b5243331e7e5</guid><dc:creator><![CDATA[juzten]]></dc:creator><pubDate>Fri, 24 Jun 2022 03:17:10 GMT</pubDate><media:content url="https://images.unsplash.com/photo-1504805572947-34fad45aed93?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=MnwxMTc3M3wwfDF8c2VhcmNofDh8fGhhY2t8ZW58MHx8fHwxNjU2MDQwNTc4&amp;ixlib=rb-1.2.1&amp;q=80&amp;w=2000" medium="image"/><content:encoded><![CDATA[<img src="https://images.unsplash.com/photo-1504805572947-34fad45aed93?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=MnwxMTc3M3wwfDF8c2VhcmNofDh8fGhhY2t8ZW58MHx8fHwxNjU2MDQwNTc4&amp;ixlib=rb-1.2.1&amp;q=80&amp;w=2000" alt="Do It Anyways"><p>So you have a really cool idea for an app, game, or solution to a problem. You get super pumped about it and start researching your idea, then the unexpected happens. You find out that somebody else has came up with the same idea and they have already produced it. This is always a downer and I am sure that everybody has felt this at least once in their life. Being a developer this has happened to me more than once, ranging from ideas about websites to potential phone apps.</p><p>A friend and I recently participated in a local hackathon. We had a general idea about what we wanted to do, we even had a handful of other people join our team which was really nice because we didn&apos;t think anybody would be interested. About half way through the day we googled our idea and it had already been done. This discouraged our teammates from wanting to move forward with our idea and they started formulating other ideas. My friend and I decided that we wanted to keep going forward with our original idea because we saw value in it. A few people went to other teams while others decided to call it quits. Long story short we ended up developing a really cool interface for the app, visualized the data better, gave it more of a local feel, and had it working right before presentation time. We ended up placing first place which we really didn&apos;t expect because the other teams had some really amazing apps by some really creative and talented people. The moral here is that if you have an idea, just because your idea has been created by another person doesn&apos;t mean that you should get discouraged and put that special idea in the past. There are ways that you can create a better product, save time, and ultimately make it cheaper.</p><p>It is all in the way that you look at this type of situation. It can actually be a good thing that your idea already exists. That means that at the very least, one other person in the world came up with the same idea. They might have came up with it early than you but this means that other people either have the same problem or want the same game and there is at least some kind of market for it. So right off the bat you know that you have a potential audience that you can target. If the other product has reviews online, this gives you a good jump because you can improve the negative things that people don&apos;t like about the current product as well as make sure your product has the positive features or features that people want to see. This all depends on how many reviews there are and how thorough they might be. You can also test out the current product to see what you think you can add in your product to make it better. By this I don&apos;t mean ripping off every feature from the product but you can test the product and treat it like an early prototype to your own to see what features you want to add or in some cases you might want to change or take away certain features. This allows you to build your product better and cheaper the first time around giving consumers a reason to use your product over the others. You can make your idea really stand out not only by making it function better but my making it look better as well. If your product is an app or website then you can polish it by giving it better graphics and a better user experience.</p><p>Make sure that everything you do to your idea is something that you want to do. As with anything, it is a lot harder to work on something you don&apos;t care about or see no value in. Ideas that you come up with and decide to carry out should ultimately reflect what you want and there is a very large chance that a multitude of people want the same thing. Ideas that you come up with and decided to turn into a personal project are really meaningful so it shouldn&apos;t matter if other people like or hate them, find value in them or contain no value at all to other people as long as they contain value to yourself. These are your personal ideas, your projects, and your way of solving a problem. If you don&apos;t carry out your ideas, thats when they are of no value to anybody. Do it anyways.</p>]]></content:encoded></item><item><title><![CDATA[Chatype All The Things]]></title><description><![CDATA[<p>I recently started dabbling with building Google Chrome extensions and Chrome apps. The experience so far has been pretty simple. There is plenty of documentation related to both extensions and apps although some of it is outdated. I have noticed that there are videos of one particular tool for easily</p>]]></description><link>http://blog.juzten.com/chatype-all-the-things/</link><guid isPermaLink="false">62b52c035ca3b5243331e7d9</guid><dc:creator><![CDATA[juzten]]></dc:creator><pubDate>Fri, 24 Jun 2022 03:15:52 GMT</pubDate><media:content url="http://blog.juzten.com/content/images/2022/06/ChatypeMascot.jpeg" medium="image"/><content:encoded><![CDATA[<img src="http://blog.juzten.com/content/images/2022/06/ChatypeMascot.jpeg" alt="Chatype All The Things"><p>I recently started dabbling with building Google Chrome extensions and Chrome apps. The experience so far has been pretty simple. There is plenty of documentation related to both extensions and apps although some of it is outdated. I have noticed that there are videos of one particular tool for easily building interfaces for apps that is very similar to building interfaces with Visual Studio for visual basic or c#. It had a drag and drop style interface and looked like a quick way to prototype an application while also being able to make it functional. Unfortunately this magnificent tool has been laid to rest by Google, from my searches of blog posts and articles this has happened because Google wanted to focus more on the html side of extensions and apps...Thanks Google.</p><p>Anyways, it only took me a day to get my first Chrome extension built and published. Probably a couple of hours of messing around actually. It was an icon in the browser that when pushed, redirected the current page to the website Chadev.com. FYI <a href="http://chadev.com/">Chadev</a> is a local Chattanooga community of developers, programmers, and like minded tech people that I help run along with a handful of other Chattanooga developers. The website is currently in the making but our current main outlet is a subreddit. More on Chadev in a future post. The Chadev extension is very simple, it has an icon, displays the text &apos;Open Chadev&apos; when hovered over, and redirects to Chadev.com when clicked. The whole extension consists of six files, four of which are images. The two code files, a javascript and manifest.json file have a total of 28 lines of code. The manifest file is probably the most important file in the extension. It holds all relevant information for the project including the name, version, description, icons, browser actions, and has references to all files used with the extension. My manifest file loads in a javascript file in the background which waits for the extension button to be clicked the does its redirection magic. All the code is open sourced and can be found at the <a href="https://github.com/chadev/chadev_chrome_extensions">Chadev Chrome Extensions</a> github repository and can be installed from Chrome web store at <a href="https://chrome.google.com/webstore/detail/chadev/olnbgmkmclbggbbffgmdmcbfcglamobo">Chadev extension</a>.</p><p>After creating the Chadev extension, I set out to create an extension to change the font type of any web page that you visit to the font Chatype, the city of Chattanooga, Tn. font type. Another simple idea but one that I find entertaining. Chattanooga has received some publicity for its specialized font type and hopefully this will help people see how it looks on different web pages. After messing around with the example code provided by google I was able to change the font on pages but I was having a problem actually loading in the Chatype font files. A fellow Chadev member and long time good friend, <a href="http://kylegordydesign.com/">Kyle Gordy</a> was able to figure out that I was missing the code in the manifest that was supposed to load in the font. After that everything was dandy. Kyle created some amazing extension icons and we shipped it off to the Chrome web store. Kyle also created the amazing graphic that is at the top of this post and is on the github repository. The Chatype All The Things extension is available at the <a href="https://chrome.google.com/webstore/detail/chatype-all-the-things/lemklljglcmkifeacmafcgofakdpbkjb">Chrome web store</a> and the open sourced code can be found on my github profile under the <a href="https://github.com/juzten/Chatype-all-the-things">Chatype all the things repository</a>.</p><p>I have a few more ideas for extensions that I want to create so keep an eye out for more of my Chrome extensions and apps as I continue to learn more about them. If you have any ideas about extensions or apps that you think would be cool or if you have created any yourself let me know. I&apos;m very interested in hearing about your experiences as well.</p>]]></content:encoded></item><item><title><![CDATA[Setting up Pyenv and Pyenv-virtualenv]]></title><description><![CDATA[<p>I want to start using python 3 but can&apos;t give up python 2.7 because of other project that rely on it. I&apos;ve had a few people mention that I should use pyenv for virtual environments in the past but I didn&apos;t feel like</p>]]></description><link>http://blog.juzten.com/setting-up-pyenv-and-pyenv-virtualenv/</link><guid isPermaLink="false">62b52a835ca3b5243331e7b6</guid><dc:creator><![CDATA[juzten]]></dc:creator><pubDate>Fri, 24 Jun 2022 03:12:22 GMT</pubDate><content:encoded><![CDATA[<p>I want to start using python 3 but can&apos;t give up python 2.7 because of other project that rely on it. I&apos;ve had a few people mention that I should use pyenv for virtual environments in the past but I didn&apos;t feel like learning another tool. Now that I want to give python 3 a try I searched around on different ways to have more than one python version on a system and Pyenv was mentioned a lot. Since I&apos;ve been in the mood to try to document how I install tools, utilize tools, pickup new techniques, etc.. I felt this is a great opportunity to both document and write a quick article about it.</p><p>Enter: <a href="https://github.com/yyuu/pyenv">pyenv</a> and <a href="https://github.com/yyuu/pyenv-virtualenv">pyenv-virtualenv</a></p><h4 id="installation-and-setup-on-mac-with-homebrew">Installation and setup on <em>mac with homebrew</em></h4><pre><code class="language-bash">brew update
brew install pyenv
brew install pyenv-virtualenv</code></pre><p>Add these lines to the end of your .zshrc/.bashrc</p><pre><code># set paths
export PATH=/usr/local/bin:$PATH
export PYENV_ROOT=&quot;$HOME/.pyenv&quot;
export PATH=&quot;$PYENV_ROOT/bin:$PATH&quot;
# initialize pyenv on terminal load
eval &quot;$(pyenv init -)&quot;
# auto ativate virtualenv for pyenv
if which pyenv-virtualenv-init &gt; /dev/null; then eval &quot;$(pyenv virtualenv-init -)&quot;; fi

# python virtual env
if [ -z ${VIRTUAL_ENV+x} ]
then
VENV_NOTICE=&quot;&quot;
else
VENV_NOTICE=&quot; (py: $(basename &quot;$VIRTUAL_ENV&quot;))&quot;
fi
</code></pre><h4 id="pyenv-commands">Pyenv Commands</h4><p>List all python versions downloaded</p><p><code>pyenv versions</code></p><p>View what python version is currently activated</p><p><code>pyenv version</code></p><p>View what python version is set to global</p><p><code>pyenv global</code></p><p>Install python version 2.7.8 or any python version</p><p><code>pyenv install 2.7.8</code></p><p>Rehash after instaling any python version</p><p><code>pyenv rehash</code></p><p>Set global python version</p><p><code>pyenv global 2.7.8</code></p><p>Set python version for current directory This also creates a .python-version in current directory</p><p><code>pyenv local 3.5.0</code></p><h4 id="pyenv-virtualenv-commands">Pyenv-virtualenv Commands</h4><p>Create virtualenv with python version 2.7.8 and name the env project_name</p><p><code>pyenv virtualenv 2.7.8 project_name pyenv virtualenv [pyenv-version] [virtualenv-name]</code></p><p>List virtualenvs already created, also shows py version for each env</p><p><code>pyenv virtualenvs</code></p><p>Activate a virtualenv from one thats already made</p><p><code>pyenv local venv_name</code></p><p>Deactivate a virtualenv</p><p><code>pyenv deactivate</code></p><h4 id="pyenv-and-pyenv-virtualenv-commands">Pyenv and Pyenv-virtualenv Commands</h4><p>Remove a Python version or virtualenv</p><p><code>pyenv uninstall &lt;virtualenv or python-version&gt;</code></p>]]></content:encoded></item><item><title><![CDATA[Reading data from a csv file in python]]></title><description><![CDATA[<p>This is a common function that I use in my code when reading in data from a csv file with python.</p><pre><code class="language-python">#!/usr/bin/env python
# -*- coding: utf-8 -*-

import csv

def get_contacts_from_csv(directory):
    contacts = []
    if directory:
        csv_location = directory + &apos;/contacts.csv&apos;
    else:</code></pre>]]></description><link>http://blog.juzten.com/reading-data-from-a-csv-file-in-python/</link><guid isPermaLink="false">62b52a265ca3b5243331e7a4</guid><dc:creator><![CDATA[juzten]]></dc:creator><pubDate>Fri, 24 Jun 2022 03:07:36 GMT</pubDate><content:encoded><![CDATA[<p>This is a common function that I use in my code when reading in data from a csv file with python.</p><pre><code class="language-python">#!/usr/bin/env python
# -*- coding: utf-8 -*-

import csv

def get_contacts_from_csv(directory):
    contacts = []
    if directory:
        csv_location = directory + &apos;/contacts.csv&apos;
    else:
        csv_location = &apos;contacts.csv&apos;

    with open(csv_location, &apos;rU&apos;) as f:
        reader = csv.reader(f)
        for row in reader:
            contacts.append([row[0], row[1], row[2], row[3].lower()])
    # remove header row if it exists.
    if contacts[0][0] == &apos;user_login&apos;:
        del contacts[0]
    return contacts

if __name__ == &quot;__main__&quot;:
    contacts_from_csv = get_staff_from_csv(&apos;home/juzten&apos;)</code></pre><p>This works really well, I can even update the function to take in a file name if I had the need to read multiple files. In line 19 I&apos;m checking if the first row is a header by checking if the first item is the contacts list is equal to what would normally be in the first row and column of the csv file, in this case it would be &apos;user_login&apos; so I&apos;m deleting that item in the contacts list. I could also skip the first row while reading in the csv but in this case I did not do that.</p><p>On line 17 I&apos;m specifically adding the first 4 rows to a list. I&apos;m also converting the 4th row to lowercase. Just for reference this is what the data from this csv would look like:</p><pre><code class="language-python">[
    [&apos;Homer&apos;, &apos;Simpson&apos;, &apos;male&apos;, &apos;35&apos;],
    [&apos;Bart&apos; , &apos;Simpson&apos;, &apos;male&apos;, &apos;12&apos;]
]</code></pre>]]></content:encoded></item><item><title><![CDATA[Python's ftp library]]></title><description><![CDATA[<p>I recently worked on a project where I needed to download a csv file from a remote ftp server periodically so I could use the file in the rest of the project. After doing some digging, I found out that python has a built-in library to do some ftp operations.</p>]]></description><link>http://blog.juzten.com/pythons-ftp-library/</link><guid isPermaLink="false">62b523225ca3b5243331e791</guid><dc:creator><![CDATA[juzten]]></dc:creator><pubDate>Fri, 24 Jun 2022 03:05:51 GMT</pubDate><content:encoded><![CDATA[<p>I recently worked on a project where I needed to download a csv file from a remote ftp server periodically so I could use the file in the rest of the project. After doing some digging, I found out that python has a built-in library to do some ftp operations. Here is a function I&apos;m using to download a file using python&apos;s ftplib library.</p><pre><code class="language-python">from ftplib import FTP

def download_file_from_ftp_server(filename):
    &quot;&quot;&quot;Download file from ftp server.&quot;&quot;&quot;
    ftp = FTP()
    ftp.connect(&quot;websitename.com&quot;, 5000)
    ftp.login(&quot;username&quot;, &quot;very_secure_password&quot;)
    localfile = open(filename, &apos;wb&apos;)
    ftp.retrbinary(&apos;RETR &apos; + filename, localfile.write, 1024)
    ftp.quit()
    localfile.close()
</code></pre><p>If the file is at the root of the webserver, then you can pass in the exact file name you want to grab. If the file is in another directory, you can pass in the directory structure to the file and the file name such as <code>reports/monday/logs.csv</code>.</p><p>This function connects and logs in to the ftp server, reads the file on the server and writes it to the local file system. It also handles closing the ftp connection and the local file after it has been created.</p>]]></content:encoded></item><item><title><![CDATA[For Loop or None]]></title><description><![CDATA[<p>Have you ever received the error: <code>TypeError: &apos;NoneType&apos; object is not iterable</code> when trying to iterate over a variable? Well, that&apos;s because you&apos;re trying to iterate over a variable that is set to None instead of an iterable like a list.</p><p>This is a</p>]]></description><link>http://blog.juzten.com/for-loop-or-none/</link><guid isPermaLink="false">62b51f965ca3b5243331e754</guid><dc:creator><![CDATA[juzten]]></dc:creator><pubDate>Fri, 24 Jun 2022 02:28:26 GMT</pubDate><content:encoded><![CDATA[<p>Have you ever received the error: <code>TypeError: &apos;NoneType&apos; object is not iterable</code> when trying to iterate over a variable? Well, that&apos;s because you&apos;re trying to iterate over a variable that is set to None instead of an iterable like a list.</p><p>This is a solution I found when trying to loop over a variable that could either be a list of items or the variable could be set to None. It feels a lot more pythonic than having to check if the variable is a list before looping over it. This was specifically happing when getting back data from sqlalchemy queries. The query can either return a list of items it found in the database or it can return None if nothing is found.</p><p>This is a sqlalchemy query, it will either return a list of people with the <code>first_name</code> of &quot;Justin&quot; or if there is no person with that first name it will return None. This is just an example of when a variable might be a list with list items or None.</p><pre><code class="language-python">people = Person.query.filter_by(first_name=&apos;Justin&apos;).all()		</code></pre><p>I&apos;m going to specifically set <code>people</code> to None here to show that <code>people</code> is actually None instead of having to look into what the above query actually returns.</p><p><code>people = None</code></p><p>If <code>people</code> was a list that contained items, the print statements in the for loop would be called. Since <code>people</code> is set to None, nothing will be printed because the empty list in the <code>or []</code>section is what gets evaluated.</p><pre><code class="language-python">for person in people or []: 
    print(person.first_name)</code></pre><h3 id="unrelated-comprehension-equivalent-but-same-concept">Unrelated comprehension equivalent but same concept</h3><pre><code class="language-python">result = [do_something(item) for item in a_list() or []]</code></pre>]]></content:encoded></item><item><title><![CDATA[Converting a list to a string in python]]></title><description><![CDATA[<p>Here I am converting a list of strings to a single string and placing a comma between each item in the new string.</p><pre><code>#!/usr/bin/env python
# -*- coding: utf-8 -*-

# convert list to string with removed []
LIST = [&apos;first&apos;, &apos;second&apos;, &apos;third&apos;, &apos;</code></pre>]]></description><link>http://blog.juzten.com/converting-a-list-to-a-string-in-python/</link><guid isPermaLink="false">62b4da8b5ca3b5243331e73f</guid><dc:creator><![CDATA[juzten]]></dc:creator><pubDate>Thu, 23 Jun 2022 21:28:23 GMT</pubDate><content:encoded><![CDATA[<p>Here I am converting a list of strings to a single string and placing a comma between each item in the new string.</p><pre><code>#!/usr/bin/env python
# -*- coding: utf-8 -*-

# convert list to string with removed []
LIST = [&apos;first&apos;, &apos;second&apos;, &apos;third&apos;, &apos;fourth&apos;]
str_list = (&quot;, &quot;.join(LIST))</code></pre><p>This is the output:</p><pre><code class="language-python">print str_list
&gt;&gt; &apos;first, second, third, fourth`</code></pre>]]></content:encoded></item></channel></rss>