<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Python Bites on PäksTech</title><link>https://www.pakstech.com/series/python-bites/</link><description>Recent content in Python Bites on PäksTech</description><generator>Hugo</generator><language>en-us</language><copyright>2021 Janne Kemppainen All rights reserved</copyright><lastBuildDate>Fri, 09 Oct 2026 12:45:01 +0300</lastBuildDate><atom:link href="https://www.pakstech.com/series/python-bites/index.xml" rel="self" type="application/rss+xml"/><item><title>Combine Multiple Filter Conditions in Python</title><link>https://www.pakstech.com/blog/python-multiple-filter/</link><pubDate>Mon, 03 Oct 2022 20:29:08 +0300</pubDate><guid>https://www.pakstech.com/blog/python-multiple-filter/</guid><description>&lt;p&gt;This problem occurred when I was trying to think of an alternative way for returning the first item from a list that matches given constraints. Using if statements inside a for loop is the obvious way to comb through the items but the built-in &lt;code&gt;filter()&lt;/code&gt; function provides an interesting alternative.&lt;/p&gt;</description></item><item><title>Run Selected Python Unit Tests from the Command Line</title><link>https://www.pakstech.com/blog/python-select-unit-test/</link><pubDate>Sat, 07 Aug 2021 20:08:25 +0300</pubDate><guid>https://www.pakstech.com/blog/python-select-unit-test/</guid><description>&lt;p&gt;It doesn&amp;rsquo;t always make sense to run the full suite of tests when you&amp;rsquo;re developing a part of a program. So how can you run only a portion of your Python unit tests on the command line?&lt;/p&gt;</description></item><item><title>Use StatsD to Measure Your Python App Metrics</title><link>https://www.pakstech.com/blog/python-statsd/</link><pubDate>Mon, 12 Jul 2021 10:40:29 +0300</pubDate><guid>https://www.pakstech.com/blog/python-statsd/</guid><description>&lt;p&gt;If you&amp;rsquo;re a fan of DevOps, then you should also be enthusiastic about collecting telemetry from your production applications. &lt;a href="https://github.com/statsd/statsd"&gt;StatsD&lt;/a&gt; is one solution that you could use to collect metrics in Python.&lt;/p&gt;</description></item><item><title>Python File Operations</title><link>https://www.pakstech.com/blog/python-file-operations/</link><pubDate>Fri, 21 May 2021 18:46:08 +0300</pubDate><guid>https://www.pakstech.com/blog/python-file-operations/</guid><description>&lt;p&gt;Knowing how to handle files in your programming language of choice is an essential skill for any developer. After reading this post you should be comfortable doing file operations in Python.&lt;/p&gt;</description></item><item><title>Show a Progress Bar in Python</title><link>https://www.pakstech.com/blog/python-progress-bar/</link><pubDate>Sat, 13 Mar 2021 19:09:04 +0200</pubDate><guid>https://www.pakstech.com/blog/python-progress-bar/</guid><description>&lt;p&gt;Python is a great language for writing command line scripts. When you need to run long running processes it is polite to indicate the overall progress to your user. You don&amp;rsquo;t want the user to think that your script has hanged and terminate the execution after a minute. Luckily, adding a progress indicator is really easy!&lt;/p&gt;</description></item><item><title>What is the Switch-Case Equivalent in Python?</title><link>https://www.pakstech.com/blog/python-switch-case/</link><pubDate>Sat, 06 Mar 2021 21:00:56 +0200</pubDate><guid>https://www.pakstech.com/blog/python-switch-case/</guid><description>&lt;p&gt;Historically, the Python syntax hasn&amp;rsquo;t had a switch-case statement. In 2006 Guido van Rossum, the original author of Python, &lt;a href="https://www.python.org/dev/peps/pep-3103/"&gt;proposed different alternatives for the switch-case syntax in PEP 3103&lt;/a&gt; but they all seemed to have some problems and the idea didn&amp;rsquo;t gain enough popular support. The proposal was therefore rejected. Python version 3.10 changes this.&lt;/p&gt;</description></item><item><title>Return Many Values as Attributes in Python</title><link>https://www.pakstech.com/blog/python-simplenamespace/</link><pubDate>Wed, 13 Jan 2021 19:43:01 +0200</pubDate><guid>https://www.pakstech.com/blog/python-simplenamespace/</guid><description>&lt;p&gt;When you need to return complex data from a function you typically think of two options:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;put the values in a dictionary&lt;/li&gt;
&lt;li&gt;create a new object/class&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The first option is simple to implement but you need to access the individual values by their keys. The second option allows you to access data via attributes and do custom calculations behind the scenes, but then you need to implement yet another class.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Is there something in Python that could give us easy attribute access without having to bother with custom classes?&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>Dynamic Attributes in Python</title><link>https://www.pakstech.com/blog/python-dynamic-attributes/</link><pubDate>Tue, 20 Oct 2020 20:58:12 +0300</pubDate><guid>https://www.pakstech.com/blog/python-dynamic-attributes/</guid><description>&lt;p&gt;When you define an object in Python you usually give it some attributes that hold the necessary pieces of information in a place that makes sense. However, Python does not limit the use of attributes to the set that were described at object creation time.&lt;/p&gt;</description></item><item><title>Chained Comparisons in Python</title><link>https://www.pakstech.com/blog/python-chained-comparisons/</link><pubDate>Wed, 07 Oct 2020 19:00:00 +0300</pubDate><guid>https://www.pakstech.com/blog/python-chained-comparisons/</guid><description>&lt;p&gt;Can you chain comparison operations in Python? Yes you can, each comparison is evaluated pairwise so you can chain together as many of them you want.&lt;/p&gt;
&lt;p&gt;It can be easy to forget to use basic features like this if you come from a language that doesn&amp;rsquo;t support chained comparisons or if you&amp;rsquo;ve never seen them used in the wild. I&amp;rsquo;ve been using Python professionally for years but I have to admit that I still didn&amp;rsquo;t really know about this feature until recently.&lt;/p&gt;</description></item><item><title>Create Simple Python GUI Applications with Gooey</title><link>https://www.pakstech.com/blog/python-gooey/</link><pubDate>Thu, 21 May 2020 18:50:29 +0300</pubDate><guid>https://www.pakstech.com/blog/python-gooey/</guid><description>&lt;p&gt;This time I&amp;rsquo;m going to show you how to create simple GUI applications in Python using a package called &lt;a href="https://github.com/chriskiehl/Gooey"&gt;Gooey&lt;/a&gt;. It lets you turn (almost) any command line Python application into a GUI application with one line.&lt;/p&gt;</description></item><item><title>Create Your Own Python Packages</title><link>https://www.pakstech.com/blog/python-create-packages/</link><pubDate>Sat, 16 May 2020 16:32:25 +0300</pubDate><guid>https://www.pakstech.com/blog/python-create-packages/</guid><description>&lt;p&gt;When programming in Python you&amp;rsquo;re used to installing packages from &lt;a href="https://pypi.org/"&gt;the Python Package Index (PyPI)&lt;/a&gt;. But how do the packages end up there? How can I make my Python code installable? Let&amp;rsquo;s find out!&lt;/p&gt;</description></item><item><title>Building URLs in Python</title><link>https://www.pakstech.com/blog/python-build-urls/</link><pubDate>Fri, 20 Mar 2020 13:19:59 +0200</pubDate><guid>https://www.pakstech.com/blog/python-build-urls/</guid><description>&lt;p&gt;Building URLs is really common in applications and APIs because most of the applications tend to be pretty interconnected. But how should we do it in Python? Here&amp;rsquo;s my take on the subject.&lt;/p&gt;</description></item><item><title>Environment Variables in Python</title><link>https://www.pakstech.com/blog/python-environment-variables/</link><pubDate>Wed, 22 Jan 2020 09:18:41 +0300</pubDate><guid>https://www.pakstech.com/blog/python-environment-variables/</guid><description>&lt;p&gt;Environment variables are key-value pairs that are defined in your shell environment outside of the Python executable. You can access them in Python with the &lt;code&gt;os.environ&lt;/code&gt; mapping object.&lt;/p&gt;
&lt;p&gt;Environment variables are really useful for passing secret information or other configurations that you don&amp;rsquo;t want to pass as command line arguments. A good use case for example is a containerized application running in Docker or Kubernetes where you can configure the application using environment variables.&lt;/p&gt;</description></item><item><title>Three Dots in Python, What is the Ellipsis Object?</title><link>https://www.pakstech.com/blog/python-ellipsis/</link><pubDate>Sat, 04 Jan 2020 20:53:16 +0300</pubDate><guid>https://www.pakstech.com/blog/python-ellipsis/</guid><description>&lt;p&gt;You might have stumbled on the Ellipsis object (&amp;hellip;) in Python and wondered what it is used for. It was originally introduced to be used in the &lt;a href="https://numpy.org/"&gt;Numeric Python&lt;/a&gt; package for matrix slicing but nothing stops you from using it for other purposes too.&lt;/p&gt;</description></item></channel></rss>