<?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>Forem: dzaeltic</title>
    <description>The latest articles on Forem by dzaeltic (@dzaeltic).</description>
    <link>https://forem.com/dzaeltic</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%2F3895094%2F39006e06-00ae-4891-b137-b77a88735724.jpeg</url>
      <title>Forem: dzaeltic</title>
      <link>https://forem.com/dzaeltic</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/dzaeltic"/>
    <language>en</language>
    <item>
      <title>Python as a JavaScript Dev</title>
      <dc:creator>dzaeltic</dc:creator>
      <pubDate>Mon, 25 May 2026 12:47:59 +0000</pubDate>
      <link>https://forem.com/dzaeltic/python-as-a-javascript-dev-51jm</link>
      <guid>https://forem.com/dzaeltic/python-as-a-javascript-dev-51jm</guid>
      <description>&lt;p&gt;This blog is an introduction to Python, and it assumes that you have a good knowledge of JavaScript as a language already. I will cover a lot of the basics we use to write code every day, and how they will look in Python compared to JavaScript. This is not to see if one language is better than the other, but rather a resource to aid JavaScript developers who want to start coding in Python for the first time. It is not comprehensive, but I do hope it helps get your foot in the door.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;BASIC SYNTAX DIFFERENCES&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
Python typically uses snake_casing instead of camelCasing, and has no variable declaration keywords. We can simply say something like:&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;my_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;dev&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Although, there is no required keyword, we can include "global" or "nonlocal" to add our variable to a scope outside of the one it was declared in. "global" will put in the global scope, and "nonlocal" will put it in the enclosing (but not global) one.&lt;/p&gt;

&lt;p&gt;Python has no semicolons or curly braces. In JavaScript we are able to be very loose with how our whitespace looks because we can indicate the end of a line with a semicolon, and curly braces to define blocks. You could even write an entire JavaScript file in one line because of this (pls don't). However, Python is very strict about whitespace. There is a whole error for these types of mistakes in Python called IndentationError. New lines of code &lt;em&gt;must _be broken by a line break, and code blocks like function bodies _must&lt;/em&gt; be indented and start with a colon.&lt;/p&gt;

&lt;p&gt;Parenthesis are reserved for Tuples (See &lt;em&gt;collection&lt;/em&gt; section), so if statements and for loops will not need their conditionals/control statements wrapped inside ().&lt;/p&gt;

&lt;p&gt;Pythons number variables are called integers, and there is another variable type, float, specifically for decimals.&lt;/p&gt;

&lt;p&gt;Some popular collection methods like .map and .filter appear as native functions on the global scope in Python:&lt;/p&gt;

&lt;p&gt;.map(cb) -&amp;gt; map(cb, col)&lt;br&gt;
.filter(cb) -&amp;gt; filter(cb, col)&lt;br&gt;
.length() -&amp;gt; len(col)&lt;br&gt;
.sort() -&amp;gt; sorted(col)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;COLLECTIONS&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;u&gt;LISTS&lt;/u&gt;&lt;br&gt;
A list in Python is what we think of as an array in JavaScript. Python lets us access specific items in the list with bracket notation as well, but a lot of the array methods we know and love like slice are included in bracket notation in Python. Some functionalities will still need to be accessed through a method. For Example: .append method. This one behaves like the .push method in JavaScript. The .pop method is named the same in both languages.&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;nums&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&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;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;# [1, 2]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;notes&lt;/em&gt;: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;this would not mutate nums&lt;/em&gt; &lt;/li&gt;
&lt;li&gt;
&lt;em&gt;console.log() = print()&lt;/em&gt; &lt;/li&gt;
&lt;li&gt;&lt;em&gt;comment = #&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some more things you can do with bracket notation:&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;nums&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;#&amp;lt;- starts on index 0
&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:]&lt;/span&gt; &lt;span class="c1"&gt;#&amp;lt;- includes through last index
&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;#&amp;lt;-includes until last index
&lt;/span&gt;&lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;#replaces 1 with 5
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;note: last example is similar to .splice method!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We can concatenate lists with the plus operator in Python!&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;nums&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;names&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;greg&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;linda&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&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt; &lt;span class="c1"&gt;# [0, 1, 2, "greg", "linda"]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python lets us manipulate lists in some more very interesting ways. We can achieve something really similar to a map and filter chain by using a loop inside of a list literal. Let me show you:&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;nums&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;double_even_nums&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;# [4]
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;notes&lt;/em&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;num * 2 -&amp;gt; what we return into the list&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;for num in nums -&amp;gt; iterate through each number in nums&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;if num % 2 == 0 -&amp;gt; only return num into new list if it passes even check&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;TUPLES&lt;/u&gt;&lt;br&gt;
Tuples are similar to lists, and are indicated by parenthesis. The main difference is that Tuples cannot be added to or removed from. Let's go over unpacking since it is helpful for tuples and lists. Similar to deconstructing in JavaScript, we can unpack values in these types of collection into other variables with handy syntax. An error will get thrown if there are too many values to unpack in a collection and not enough provided variables.&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;nums&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt; &lt;span class="c1"&gt;# a = 1, b = 2, c = [3, 4]
&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt; &lt;span class="c1"&gt;# a = 1, b = [2, 3], c = 4
&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt; &lt;span class="c1"&gt;# a = 1, b = 2, c = 4, d = 4
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;note: The asterisk lets me fill a variable with remaining variables to avoid an error.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;u&gt;DICTIONARIES&lt;/u&gt;&lt;br&gt;
A dictionary is similar to what we think of as an object in JavaScript. A dictionary literal will be enclosed in curly braces, and similar to JSON, the key names must be in quotes.&lt;/p&gt;

&lt;p&gt;We cannot use dot notation to access dictionary values, and must use bracket instead. If you lookup something that is not included in the dictionary, it will throw an error. To avoid this, though, use the .get method. The second argument for .get will specify what to print if the key you specified was not found.&lt;/p&gt;

&lt;p&gt;There are still many methods you will recognize like .keys and .values (these will return lists). To grab the key/value pairs use .items (this will return a list of tuples).&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;person&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;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;dev&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;age&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;23&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;person&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;# "dev"
&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;person&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;fav_food&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;not found&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c1"&gt;# "not found"
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;CODE BLOCKS&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;u&gt;IF STATEMENTS&lt;/u&gt;&lt;br&gt;
Python is "strongly typed", so there is only one equality comparison operator: ==. There is one exception for comparing integers to float. These can return true on equality comparison even though they are technically different variable types.&lt;/p&gt;

&lt;p&gt;We can also check if two objects occupy the same space in memory by using the keyword "is". This is super handy to be built into the language!&lt;/p&gt;

&lt;p&gt;Instead of saying "else if", Python uses the keyword "elif". Keywords "and", "or", and "not" are used instead of &amp;amp;&amp;amp;, ||, and !&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="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;has_license&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;true&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;You can drive&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;has_license&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;You cannot drive&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;else&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="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;How did we get here?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;FOR LOOPS&lt;/u&gt;&lt;br&gt;
We use the keyword "range" to specify how long to loop. There are still for in loops to go through collections, and they are comprehensive in Python, meaning it will work for any collection.&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;animals&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;dog&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;Spike&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;cat&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;Tom&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;mouse&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;Jerry&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;animal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;animals&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&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;animal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# "dog" "Spike" "cat" "Tom" "mouse"...
&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&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;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# 1, 2, 3, 4, 5
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;FUNCTIONS&lt;/u&gt;&lt;br&gt;
Functions are the only exception to the fact that variables do not need a keyword upon declaration in Python. The reason is that we have many keywords to specify the type of function that we are writing:&lt;/p&gt;

&lt;p&gt;def - basic function (default)&lt;br&gt;
lambda - defines a callback function&lt;br&gt;
class - defines a class object&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="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;


&lt;span class="n"&gt;nums&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;double_nums&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c1"&gt;# [4, 8, 12]
&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Cat&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;color&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;named_meow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;meow says &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

    &lt;span class="nd"&gt;@staticmethod&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;meow&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;meowwww&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="n"&gt;tom&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Cat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Tom&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;gray&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;notes&lt;/em&gt;: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;"self" behaves like "this" in classes, and must be passed in as a param&lt;/em&gt; &lt;/li&gt;
&lt;li&gt;
&lt;em&gt;init is like a super function&lt;/em&gt; &lt;/li&gt;
&lt;li&gt;
&lt;em&gt;If a method does not use "self", define it as a static method&lt;/em&gt; &lt;/li&gt;
&lt;li&gt;&lt;em&gt;A formatted string (f"string") lets us use a template literal. Similar to backticks in JavaScript&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Must wrap map() in list() because map does not return a list by default, but rather a map object. It returns this to save memory if conversion is not necessary&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Well, this covered a lot, and I'm sure you experienced JavaScript developers still have some questions about how to do things in Python that I didn't answer. There were some things like maps, sets, etc... that I left out for time sake. I also didn't explain how any of these pieces work because, like I said earlier, this blog assumes you already know how to write code in JavaScript. I know it is a little bit of a niche, but hopefully it helps someone! Happy coding!&lt;/p&gt;

</description>
      <category>python</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>What makes a good codebase?</title>
      <dc:creator>dzaeltic</dc:creator>
      <pubDate>Thu, 30 Apr 2026 01:59:10 +0000</pubDate>
      <link>https://forem.com/dzaeltic/what-makes-a-good-codebase-1a2h</link>
      <guid>https://forem.com/dzaeltic/what-makes-a-good-codebase-1a2h</guid>
      <description>&lt;p&gt;I am a currently student in a coding bootcamp. We have been focusing a lot on JavaScript, as we start to build fundamentals. Recently, as we have started exploring GitHub, CSS, and HTML, I've started to get exposed to larger codebases, and I've realized there is a lot that can be going on in one project. Collaboration is huge in development it seems, so having good fundamentals with how I layout codebases seems really important to me.&lt;/p&gt;

&lt;p&gt;I say collaboration, and you probably immediately were thinking with other developers. While, yes, I was, I want to clarify that I am also talking about development with A.I. I know that my teachers don't really want me using A.I. to write code and I completely understand. It is a super powerful tool, and can easily become a crutch that hinders my learning largely. But, I would be a fool to not explore some coding with A.I on the side, and as I have, I have noticed that it can be hard to reign in the A.I. to actually fix the problem I need it to fix or even understand what the problem may be. Obviously, this is largely about the prompts I am giving it which could be improved upon. Communication is key to reaching a good codebase whether you are working with a person or AI!!&lt;/p&gt;

&lt;p&gt;With clear instructions, the A.I is great at writing our code, saving us lots of time, but as a codebase grows, it gets harder and harder to communicate our vision and what our codebase should be doing as a whole. When it just solves problems through a lens without understanding the bigger picture, it leads to more modules. Simpler, but more. This gets harder to organize and navigate and becomes a problem as other developers struggle to understand what is happening in your codebase. Good codebases rely on more complex modules that have simpler interfaces, more functionality, and hidden complexity! &lt;/p&gt;

&lt;p&gt;Tests, tests, tests! You have probably heard of T.D.D. (test driven development), but do you understand why it is important. This is what helps us communicate and focus on our main goal. Writing a test forces you to start with functionality. How does my code actually need to function? What possible bugs will I run into? These types of larger picture goals help to bridge the gap between two developers or AI and developer, so that  goals can be reached more efficiently. &lt;/p&gt;

&lt;p&gt;There is still a lot I don't understand in this field, but I can draw on my other life experiences to know that these things are key to building a good codebase. I didn't try to give micro-level tips and tricks because I am in no position to do so. Most people who read this will probably be more experienced at making codebases than I am. &lt;/p&gt;

&lt;p&gt;I'm excited to start making my own codebases and applying what I've learned so far. I want to focus on designing architecture, making layouts that a toddler could understand. I want my code's purpose to be clear, and easy to edit. This is what makes a good codebase.  &lt;/p&gt;

&lt;p&gt;Also, I want to give some code examples of smaller snippets of code that may lead to larger problems when designing codebases.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5n1ztrge7xxbrfalm4gt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5n1ztrge7xxbrfalm4gt.png" alt=" " width="167" height="93"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;▲ In this example, it is hard to tell what these variables actually mean, so it is more encouraged to use named variables. This helps collaborators tell what is going on. Like this ▼&lt;/em&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpt76392fm46v9ssgpg7v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpt76392fm46v9ssgpg7v.png" alt=" " width="322" height="113"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8gn09ueqzyjphhz4jbw0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8gn09ueqzyjphhz4jbw0.png" alt=" " width="263" height="198"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;▲ In this example, we can see many if statements nested into each other. This can get confusing for readers, and it is more encouraged to instead use operators to fit this logic into one line. Like this ▼&lt;/em&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl71f3d7z9pds8zbndi5m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl71f3d7z9pds8zbndi5m.png" alt=" " width="490" height="96"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2oi5582lkmv52v10iof8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2oi5582lkmv52v10iof8.png" alt=" " width="216" height="25"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;▲ What is 86400?? How will collaborators know what you are referring to? Try to give context to your variables ▼&lt;/em&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkbryc1emkv7a3qmp1rmr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkbryc1emkv7a3qmp1rmr.png" alt=" " width="306" height="45"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Communication is huge, and we can become better communicators in our code as well as our English.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>javascript</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>jQuery</title>
      <dc:creator>dzaeltic</dc:creator>
      <pubDate>Mon, 27 Apr 2026 14:51:47 +0000</pubDate>
      <link>https://forem.com/dzaeltic/jquery-53jk</link>
      <guid>https://forem.com/dzaeltic/jquery-53jk</guid>
      <description>&lt;p&gt;jQuery is  a JavaScript library that makes it easier to interact with elements on your page. It uses this syntax:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$(selector).action()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You can select HTML elements by #class, .id, or with a tag like &lt;/p&gt;
&lt;p&gt;. Non-existing elements can also be selected with the $ function, and they will be created. &lt;/p&gt;

&lt;p&gt;By selecting an HTML element, we create an array-like object that stores many useful methods. We can add elements before and after with append and prepend, add a class, animate, and much more. It is important to not that it is an array-like &lt;em&gt;object&lt;/em&gt; for iteration over selected elements.&lt;/p&gt;

&lt;p&gt;One important method to note is .css. We can grab an html  element, and edit any css property on the fly in our JavaScript code. It would look something like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$('p').css('color', 'black')&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Note that many jQuery methods will return the object with all the methods in it, so chaining them together is possible.&lt;/p&gt;

&lt;p&gt;Lastly, jQuery is great for handling events! Using the .on method, we can define an event like 'click' or 'hover', and write a function to be executed upon such an event. This allows to create dynamic elements on our page that the user can interact with.&lt;/p&gt;

&lt;p&gt;It's important to know jQuery because of it's broad usage over the course of the internet's history, but it is also important to note another library called react. React may be imperative to use if your project involves a large number of elements, as it is more efficient with these types of projects. I would encourage looking it up and comparing the pros and cons of both!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
