<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Harlin Seritt</title>
    <description>The latest articles on DEV Community by Harlin Seritt (@hseritt).</description>
    <link>https://dev.to/hseritt</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F999896%2Fcc2cf929-eadf-42b3-83ff-f90cd290adea.jpeg</url>
      <title>DEV Community: Harlin Seritt</title>
      <link>https://dev.to/hseritt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hseritt"/>
    <language>en</language>
    <item>
      <title>Concatenating Python Dictionaries</title>
      <dc:creator>Harlin Seritt</dc:creator>
      <pubDate>Sat, 06 Jan 2024 13:12:27 +0000</pubDate>
      <link>https://dev.to/hseritt/concatenating-python-dictionaries-52jl</link>
      <guid>https://dev.to/hseritt/concatenating-python-dictionaries-52jl</guid>
      <description>&lt;p&gt;When I'm working with Django I often like to create a base context which is a Python dict for a set of views and initially define them outside of each view. Within each view, instead of creating a new context, I prefer to update the context.&lt;/p&gt;

&lt;p&gt;So, with Python, you can combine two dictionaries in a couple of different ways. Here are two methods:&lt;/p&gt;

&lt;p&gt;Using update() Method:&lt;/p&gt;

&lt;p&gt;You can think of dictionaries in Python like collections of information. Let's say you have two dictionaries, each with some details:&lt;/p&gt;

&lt;p&gt;Dictionary 1: It contains information about a person named Sarah, like her age (15) and the number of books she has (3).&lt;/p&gt;

&lt;p&gt;Dictionary 2: Now, you want to add more information to Dictionary 1, like Sarah's new age (16) and the fact that she got a new bicycle.&lt;/p&gt;

&lt;p&gt;When you use the update() method, it's like taking the information from Dictionary 2 and adding it to Dictionary 1:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;dict1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;app_name&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;MyApp&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;def_page_title&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Welcome to MyApp&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;dict2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;objects&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;MyModel&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;objects&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;is_active&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;

&lt;span class="n"&gt;dict1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dict2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dict1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    'app_name': 'MyApp',
    'def_page_title': 'Welcome to MyApp',
    'objects': MyModel.objects.filter(is_active=True)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using the Unpacking Operator (**):&lt;/p&gt;

&lt;p&gt;You can also use the ** operator.&lt;/p&gt;

&lt;p&gt;Let's use a simple example.&lt;/p&gt;

&lt;p&gt;Imagine you have two sets of information about a person named David:&lt;/p&gt;

&lt;p&gt;Set 1: It mentions David's favorite color (blue) and the number of pets he has (2 cats).&lt;/p&gt;

&lt;p&gt;Set 2: Now, you want to combine Set 1 and Set 2 into a single set of information.&lt;/p&gt;

&lt;p&gt;You can do this using the unpacking operator (**), which creates a new set of information by putting together everything from both sets:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;set1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;color&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;blue&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;pets&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;2 cats&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;set2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;color&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;green&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;hobby&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;playing chess&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;combined_set&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;set1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;set2&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;combined_set&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result will be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{'color': 'green', 'pets': '2 cats', 'hobby': 'playing chess'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In both cases, you're adding or merging information to create a more complete set of details, just like updating or combining facts about a person. Both ways work the same. But for me using {...}.update({...}) seems more readable.&lt;/p&gt;

</description>
      <category>python</category>
      <category>dict</category>
    </item>
    <item>
      <title>Understanding CSS Media Types: Making Your Website Look Good on Different Devices</title>
      <dc:creator>Harlin Seritt</dc:creator>
      <pubDate>Thu, 04 Jan 2024 14:38:25 +0000</pubDate>
      <link>https://dev.to/hseritt/understanding-css-media-types-making-your-website-look-good-on-different-devices-4f0m</link>
      <guid>https://dev.to/hseritt/understanding-css-media-types-making-your-website-look-good-on-different-devices-4f0m</guid>
      <description>&lt;p&gt;When you design a website, you want it to look nice and work well, whether people are viewing it on a computer, phone, or even if they're printing it out. CSS (Cascading Style Sheets) helps with this, and one important part of CSS is something called "media types."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Are CSS Media Types?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the world of websites, not all screens are the same. There are big computer screens, small phone screens, and even printers. Each of these devices is different, and that's where media types come in.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"screen" Media Type: For Devices with Screens&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The most common media type is "screen." This one is all about making your website look good on screens, like computers and phones. When you design a website, you mainly focus on this media type because that's where people see your website visually.&lt;/p&gt;

&lt;p&gt;By using "screen" media type, you can make sure your website adjusts to different screen sizes and shapes. This way, your website will look great and work properly, no matter what device someone is using.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"print" Media Type: Getting Ready for Printing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sometimes people want to print web pages. That's where the "print" media type comes in handy. It's like making a special version of your website that's easy to print. This ensures that when someone prints your web page, it looks neat and is easy to read on paper.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"speech" Media Type: Helping Those Who Can't See the Screen&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Accessibility is important in web design. The "speech" media type helps people who can't see the screen. It's for those who use special tools that read web content out loud. By using this media type, you can tell these tools how to read your content, making it easier for everyone to understand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Media Types Are Important&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Media types are like tools that help you make sure your website works well for everyone. Here's why they matter:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Better for Everyone&lt;/strong&gt;: When you use media types, your website works nicely on all sorts of devices. This makes more people happy when they visit your site.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Easy to Print&lt;/strong&gt;: The "print" media type helps people get good printouts of your web content.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Accessible&lt;/strong&gt;: "Speech" media type makes sure everyone, including those with disabilities, can access your content.&lt;/p&gt;

&lt;p&gt;Knowing how to use CSS media types is a big deal in web design. It helps you create a website that looks good and works well on different devices. It's not just about making it pretty; it's about making sure your website reaches as many people as possible in a friendly way.&lt;/p&gt;

&lt;p&gt;So, in the world of web design, don't forget about media types. They're like a superpower that makes your website awesome for everyone.&lt;/p&gt;

</description>
      <category>css</category>
      <category>media</category>
      <category>screen</category>
    </item>
  </channel>
</rss>
