<?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: dzaeltic</title>
    <description>The latest articles on DEV Community by dzaeltic (@dzaeltic).</description>
    <link>https://dev.to/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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3895094%2F39006e06-00ae-4891-b137-b77a88735724.jpeg</url>
      <title>DEV Community: dzaeltic</title>
      <link>https://dev.to/dzaeltic</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dzaeltic"/>
    <language>en</language>
    <item>
      <title>Text Processing &amp; Networking with Linux Commands (Part 2)</title>
      <dc:creator>dzaeltic</dc:creator>
      <pubDate>Mon, 10 Aug 2026 13:46:35 +0000</pubDate>
      <link>https://dev.to/dzaeltic/text-processing-networking-with-linux-commands-part-2-500e</link>
      <guid>https://dev.to/dzaeltic/text-processing-networking-with-linux-commands-part-2-500e</guid>
      <description>&lt;p&gt;This post is a continuation to my post from two weeks ago where I talked about Linux commands for file management.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;2&amp;gt;&lt;/code&gt;&lt;br&gt;
Redirects standard error instead of standard output. Useful when a command is throwing warnings or errors you want to save separately from its normal output.&lt;br&gt;
Usage: &lt;code&gt;command 2&amp;gt; errors.log&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;2&amp;gt;&amp;amp;1&lt;/code&gt;&lt;br&gt;
Redirects standard error into the same stream as standard output, so both end up in the same place. Commonly paired with &lt;code&gt;&amp;gt;&lt;/code&gt; to capture everything a command prints.&lt;br&gt;
Usage: &lt;code&gt;command &amp;gt; output.log 2&amp;gt;&amp;amp;1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;!!&lt;/code&gt;&lt;br&gt;
Re-runs the last command you typed. Useful for when &lt;code&gt;sudo&lt;/code&gt; was forgotten &lt;br&gt;
Usage: &lt;code&gt;sudo !!&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;TEXT PROCESSING&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sort&lt;/code&gt;&lt;br&gt;
Sorts the lines of a file or input alphabetically by default. The &lt;code&gt;-n&lt;/code&gt; flag sorts numerically instead of as text, &lt;code&gt;-r&lt;/code&gt; reverses the order, and &lt;code&gt;-k&lt;/code&gt; lets you sort by a specific column.&lt;br&gt;
Usage: &lt;code&gt;sort -n scores.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;uniq&lt;/code&gt;&lt;br&gt;
Filters out repeated adjacent lines, either removing duplicates or, with &lt;code&gt;-c&lt;/code&gt;, counting how many times each line occurs. &lt;br&gt;
Usage: &lt;code&gt;sort names.txt | uniq -c&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;wc&lt;/code&gt;&lt;br&gt;
Word Count. Prints the number of lines, words, and bytes in a file. Use &lt;code&gt;-l&lt;/code&gt; for just lines, &lt;code&gt;-w&lt;/code&gt; for just words, or &lt;code&gt;-c&lt;/code&gt; for just bytes.&lt;br&gt;
Usage: &lt;code&gt;wc -l access.log&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cut&lt;/code&gt;&lt;br&gt;
Pulls out a specific section from each line of input, usually a column in delimited text like a CSV. The &lt;code&gt;-d&lt;/code&gt; flag sets the delimiter and &lt;code&gt;-f&lt;/code&gt; picks which fields to keep.&lt;br&gt;
Usage: &lt;code&gt;cut -d ',' -f 2 contacts.csv&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;tr&lt;/code&gt;&lt;br&gt;
Translates or deletes characters from input, one for one. Good for quick jobs like changing case or stripping out unwanted characters. It only reads from standard input, so it's always used with a pipe or redirect.&lt;br&gt;
Usage: &lt;code&gt;cat notes.txt | tr 'a-z' 'A-Z'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sed&lt;/code&gt;&lt;br&gt;
Stream editor. Reads input line by line and applies an edit to each one, most commonly a find-and-replace using the &lt;code&gt;s/pattern/replacement/&lt;/code&gt; syntax. Add a &lt;code&gt;g&lt;/code&gt; at the end to replace every match on a line, not just the first.&lt;br&gt;
Usage: &lt;code&gt;sed 's/http/https/g' urls.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;awk&lt;/code&gt;&lt;br&gt;
A small programming language built for working with columnar text. It automatically splits each line into fields you can reference as &lt;code&gt;$1&lt;/code&gt;, &lt;code&gt;$2&lt;/code&gt;, and so on, with &lt;code&gt;$0&lt;/code&gt; meaning the whole line. It's overkill for simple jobs but worth understanding once you need conditions or math on your columns.&lt;br&gt;
Usage: &lt;code&gt;awk '{print $1, $3}' access.log&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;xargs&lt;/code&gt;&lt;br&gt;
Takes lines from standard input and turns them into arguments for another command. Many commands, like &lt;code&gt;rm&lt;/code&gt; or &lt;code&gt;grep&lt;/code&gt;, don't read from a pipe directly, so &lt;code&gt;xargs&lt;/code&gt; is what lets you feed piped output into them.&lt;br&gt;
Usage: &lt;code&gt;find . -name "*.tmp" | xargs rm&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;NETWORKING&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ping&lt;/code&gt;&lt;br&gt;
Sends small packets to a host and reports how long they take to come back, confirming whether a machine is reachable at all. Runs continuously until you stop it with ctrl+c, unless you cap it with &lt;code&gt;-c&lt;/code&gt;.&lt;br&gt;
Usage: &lt;code&gt;ping -c 4 google.com&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;curl&lt;/code&gt;&lt;br&gt;
Transfers data to or from a server over HTTP, FTP, and other protocols. By default it just prints the response body, but flags like -I (headers only), -o (save to file), and &lt;code&gt;-X&lt;/code&gt; (set the request method) make it more flexible.&lt;br&gt;
Usage: &lt;code&gt;curl -I https://example.com&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;wget&lt;/code&gt;&lt;br&gt;
Downloads files from the web straight to disk. Where &lt;code&gt;curl&lt;/code&gt; is built for talking to APIs and inspecting responses, &lt;code&gt;wget&lt;/code&gt; is built for grabbing a file and saving it, including recursively pulling down a whole page with its assets.&lt;br&gt;
Usage: &lt;code&gt;wget https://example.com/file.zip&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ip&lt;/code&gt;&lt;br&gt;
Shows and configures network interfaces, addresses, and routing on the machine. The older &lt;code&gt;ifconfig&lt;/code&gt; command does something similar but is considered deprecated on most modern distros in favor of &lt;code&gt;ip&lt;/code&gt;.&lt;br&gt;
Usage: &lt;code&gt;ip a&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ss&lt;/code&gt;&lt;br&gt;
Lists the network sockets currently open on the machine, such as which ports are listening for connections. The &lt;code&gt;-t&lt;/code&gt; flag limits it to TCP, &lt;code&gt;-u&lt;/code&gt; to UDP, &lt;code&gt;-l&lt;/code&gt; to listening sockets, and &lt;code&gt;-n&lt;/code&gt; skips resolving names so it runs faster.&lt;br&gt;
Usage: &lt;code&gt;ss -tuln&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;dig&lt;/code&gt;&lt;br&gt;
Queries DNS servers directly and shows the full result, which makes it the go-to tool for debugging why a domain isn't resolving the way you expect.&lt;br&gt;
Usage: &lt;code&gt;dig example.com&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ssh&lt;/code&gt;&lt;br&gt;
Secure Shell. Opens an encrypted terminal session on a remote machine, as if you were sitting in front of it. Requires an account on the remote machine, identified as &lt;code&gt;user@host&lt;/code&gt;.&lt;br&gt;
Usage: &lt;code&gt;ssh user@192.168.1.10&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;scp&lt;/code&gt;&lt;br&gt;
Secure Copy. Copies files between machines over the same encrypted connection SSH uses. The syntax mirrors &lt;code&gt;cp&lt;/code&gt;, just with a &lt;code&gt;user@host:&lt;/code&gt; prefix on whichever side is remote.&lt;br&gt;
Usage: &lt;code&gt;scp report.pdf user@192.168.1.10:/home/user/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Hopefully this gave some more insight as to how the Linux terminal can be a powerful place to do online work.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>devops</category>
      <category>linux</category>
      <category>terminal</category>
    </item>
    <item>
      <title>File Management with Linux Commands</title>
      <dc:creator>dzaeltic</dc:creator>
      <pubDate>Mon, 27 Jul 2026 02:42:58 +0000</pubDate>
      <link>https://dev.to/dzaeltic/file-management-with-linux-commands-58jn</link>
      <guid>https://dev.to/dzaeltic/file-management-with-linux-commands-58jn</guid>
      <description>&lt;p&gt;These are the basic commands that will help you move around and manage your file system from inside the Linux terminal. Before going over any of the commands; though, these are some variables/operators you should know first. This lets us shorthand common things to type and chain commands together in powerful ways.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;*&lt;/code&gt;&lt;br&gt;
The wildcard. This can represent any text when searching. For example: if you want to search for &lt;em&gt;all&lt;/em&gt; photos you could use the wildcard followed by jpg, png, etc. &lt;code&gt;*.png&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;|&lt;/code&gt;&lt;br&gt;
The pipe. This is a very handy operator that lets us take the output from one command and give it straight to the second command following the pipe.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;amp;&lt;/code&gt;&lt;br&gt;
The single ampersand. If your command starts a process, appending the ampersand to it will run the process in the background instead of occupying your terminal.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt;&lt;br&gt;
The double ampersand. This operator will only execute the second command following the operator if the first one was successful.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.&lt;/code&gt;&lt;br&gt;
The period. This is a shortcut to the current working directory, so you don't have to type out the whole path to where you are.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;;&lt;/code&gt;&lt;br&gt;
The semicolon. Run many commands in one line if they are separated by this operator. This lets them run independently of each other.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;gt;&lt;/code&gt;&lt;br&gt;
This operator takes the output of a command and overwrites the following file with that output.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;gt;&amp;gt;&lt;/code&gt;&lt;br&gt;
Similar to the single greater than, but it will append to the file instead of overwriting it.&lt;/p&gt;

&lt;h2&gt;
  
  
  HELP
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;--help&lt;/code&gt;&lt;br&gt;
A more concise version of the man command that prints to the terminal instead of entering another interface. This command is used as a flag to other commands.&lt;br&gt;
 Usage: &lt;code&gt;cat --help&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;man&lt;/code&gt;&lt;br&gt;
The man command is used to pull up the manual on other commands. The manual will be a text interface over the terminal, and can be exited by inputting q. This will have a summary information about usage of the command as well as information about all flags that can be appended to the command. This is also where you can find any arguments a command may take. &lt;br&gt;
 Usage: &lt;code&gt;man ls&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;info&lt;/code&gt;&lt;br&gt;
A more detailed version of the manual. This page often includes examples as well as more detailed descriptions. &lt;br&gt;
 Usage: &lt;code&gt;info cat&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  FILE NAVIGATION
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;ls&lt;/code&gt;&lt;br&gt;
This command lists children of the current directory. By default, it does not display hidden files, but they can be toggled on with the -a flag. By default this command will only display the files’ name, but more info can be displayed with the -l flag. This will show user’s privileges on a file such as read, write, and execute privileges, and other info like size.&lt;br&gt;
 Usage: &lt;code&gt;ls -l&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cd&lt;/code&gt;&lt;br&gt;
This command changes the current working directory. It takes one argument of a file path. Use &lt;code&gt;cd ..&lt;/code&gt; to move back a directory.&lt;br&gt;
 Usage: &lt;code&gt;cd photos&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pwd&lt;/code&gt;&lt;br&gt;
Print Working Directory. This one is self explanatory. It prints the path to the current working directory.&lt;br&gt;
 Usage: &lt;code&gt;pwd&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cat&lt;/code&gt;&lt;br&gt;
Concatenate files and print to the terminal. Ideal for quickly printing the contents of smaller files. &lt;br&gt;
 Usage: &lt;code&gt;cat file.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;less&lt;/code&gt;&lt;br&gt;
Less is like cat but for larger files. Will print the files in pages, so they can be viewed one at a time. Use space to go forward a page and backspace to go backwards. q to quit.&lt;br&gt;&lt;br&gt;
 Usage: &lt;code&gt;less file.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;tail&lt;/code&gt;&lt;br&gt;
Quickly print the last few lines in a file to the terminal. This is good to view the end of a file without leaving the CLI. &lt;br&gt;
 Usage: &lt;code&gt;tail file.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;head&lt;/code&gt;&lt;br&gt;
Quickly print the first few lines in a file to the terminal. This is good to view the beginning of a file without leaving the CLI. &lt;br&gt;
 Usage: &lt;code&gt;head file.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;grep&lt;/code&gt;&lt;br&gt;
This command prints lines from a file where text matching an input pattern is found. The first argument after any option flags or switches is the pattern. The pattern may be a string or regular expression. The second argument will be the files to be searched. Zero or more may be input. The file argument is optional because grep can also be chained with the pipe operator to search that output instead of a file. Grep is especially useful when used like that! The -v flag will reverse grep to print every line not including an input pattern. &lt;br&gt;
 Usage: &lt;code&gt;grep “install” README.md&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;find&lt;/code&gt;&lt;br&gt;
Find files and directories based on various criteria. The first argument will specify the directory to start the search in, and the following arguments will be the criteria to search for. For example, we can search for -type f for just files or -type d for just directories. We can also search by name with -name “cat.jpeg”.&lt;br&gt;
 Usage: &lt;code&gt;find . -type f -name “*.pdf”&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;which&lt;/code&gt;&lt;br&gt;
This command returns all executable files for a shell command. Packages like unzip, nmap, docker, etc. that have a shell command are located within a directory, and the exact location of the file that executes when these commands run can be found with which. &lt;br&gt;
 Usage: &lt;code&gt;which docker&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;whereis&lt;/code&gt;&lt;br&gt;
The whereis command can locate the binary, source, and manual page for a command. &lt;br&gt;
 Usage: &lt;code&gt;whereis docker&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  FILE MANAGEMENT
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;touch&lt;/code&gt;&lt;br&gt;
Touch makes a file. Many file names can be input to make multiple files at once. Touch can also edit the timestamps on files that already exist. &lt;br&gt;
 Usage: &lt;code&gt;touch file1.txt file2.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mkdir&lt;/code&gt;&lt;br&gt;
This command will make a new directory if it does not already exist. Many directory arguments may be passed in to make multiple directories. Permissions may be set with the -m flag. &lt;br&gt;
 Usage: &lt;code&gt;mkdir photos&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rm&lt;/code&gt;&lt;br&gt;
Removes a file. This command cannot remove directories by default. The -r flag must be used for directories, indicating recursive removal. Note: files removed with rm can usually be recovered. Use shred for more assurance that a file will be unrecoverable. &lt;br&gt;
 Usage: &lt;code&gt;rm -r photos&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cp&lt;/code&gt;&lt;br&gt;
Copies files or directories to a target destination. Typically, two arguments are passed in with the first being the source to be copied and the second being the destination to be copied to. The -t flag can flip the order where the first argument is a directory and the following arguments are files to be copied into it. &lt;br&gt;
Usage: &lt;code&gt;cp -t photos cat.jpeg dog.jpeg&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mv&lt;/code&gt;&lt;br&gt;
Moves or renames files or directories. If two file names are given, the first will be moved to the second, effectively renaming it. The -t flag works similarly to the cp command.&lt;br&gt;
 Usage: &lt;code&gt;mv -t photos cat.jpeg dog.jpeg&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;This was a basic overview of how to start using commands to interact with your Linux file system. There are many more commands to Linux built in and even more that can be installed through packages. &lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>cli</category>
      <category>linux</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Network Ports</title>
      <dc:creator>dzaeltic</dc:creator>
      <pubDate>Mon, 13 Jul 2026 03:29:04 +0000</pubDate>
      <link>https://dev.to/dzaeltic/network-ports-pb4</link>
      <guid>https://dev.to/dzaeltic/network-ports-pb4</guid>
      <description>&lt;p&gt;There are two types of "ports". There are the physical ports that are on the back of a network router or switch, and there are the virtual ports that live inside of a computer. They are not so different, though. Both of these ports will have a role in the journey of data transfer.&lt;/p&gt;

&lt;p&gt;Data is sent in packets to break up information into smaller bites. Each packet gets attached meta data called headers about where it is going. The IP address tells the packet which network to travel to, and once a packet reaches a network, the physical port tells it which MAC address(computer) it is going to. Then, it will be able to find the correct computer, but only once the network port is read, will the data know how to be processed. &lt;/p&gt;

&lt;p&gt;A computer can have many processes, services and applications running at the same time over the same network. One computer can send an email from port 587 at the same time it is receiving video data from a video server over port 443. Because data can be so varied, we need ports to make sure the correct services on our computer receive the right data.&lt;/p&gt;

&lt;p&gt;There are over 65000 available ports on a computer, and much of the lower range of them are either well-known ports or registered ports. This lets us organize them by service, and keep better track of what type of data should be flowing through that port and how.&lt;/p&gt;

&lt;p&gt;For example. If we see packets coming and going from port 22 and 23, we can expect a TELNET or SSH connection. Both of which allow for remote access of a device. This is the type of connection that lets us configure rented virtual machines and host a server on it. The more predictable packets are, the easier it is to spot malformed or suspicious data.&lt;/p&gt;

&lt;p&gt;Historically, some of the well-known ports transferred data in clear text. With the example I just gave, remote access used to be on TELNET first, but all data was sent in clear text, making it easy for hackers to decipher data that could be sensitive. Many times authentication is needed for access to something like a remote access shell, so if credentials get sent in plain text, anyone could intercept those and use it to authenticate themselves falsely. SSH, on the other hand, establishes a secure connection tunnel where data is encrypted during transfer. Other ports have been migrated to support encryption as well. For example, port 80 for HTTP (web services) is encrypted on port 443 for HTTPS.&lt;/p&gt;

&lt;p&gt;When checking for a network's vulnerabilities, most attackers start with a port scan. If a port scan returns outdated ports, like TELNET, being open, this could be a clear indicator that intercepting those packets may have sensitive data in plain text. This is exactly what firewalls defend against.&lt;/p&gt;

&lt;p&gt;Port scans are an easy terminal command to run, and they can be ran stealthily. Networks may never even know that their network ports were scanned. &lt;code&gt;nmap -sS 192.168.1.1&lt;/code&gt; This command scans thousands of ports per second, and will gives clear, reliable differentiation between open, closed, and filtered states ports may be in.&lt;/p&gt;

&lt;p&gt;A simple firewall intercepts packets and reads the headers off of it. Firewalls can be configured to deny traffic (blacklist) or accept traffic (whitelist) to specific ports or IPs. This allows us to close ports that we don't need open. It can also let us allow only specific IP address's into ports. &lt;/p&gt;

&lt;p&gt;We can look at an event called WannaCrypt from 2017 to see how devastating this type of thing can be. Port 445. Used for file/printer sharing on windows machines. A specially crafted packet allowed for an attacker to run code on a target with no login credentials needed. Once one machine was infected, it automatically scanned surrounding networks to look for any devices accepting TCP traffic on port 445. It spread by sending the same exploit to all of them.&lt;/p&gt;

&lt;p&gt;This hack spread to over 150 countries, infecting an estimated 200,000+ systems with &lt;em&gt;days&lt;/em&gt;. It impacted major industries including health, mail, and phone. &lt;/p&gt;

&lt;p&gt;Six weeks later, the same exploit was used to hit machines with a credential-stealing tool to also spread to already patched machines.&lt;/p&gt;

&lt;p&gt;The worst part about this hack is that it could've been avoided by patching regularly. Microsoft had already known about the exploit before the hack and released a patch about a month before it happened. &lt;/p&gt;

&lt;p&gt;Ports are vital for networking and sending data to the right places, but can also be a weak point without proper security precautions.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>computerscience</category>
      <category>learning</category>
      <category>networking</category>
    </item>
    <item>
      <title>KEY PYTHON CYBERSEC LIBRARIES</title>
      <dc:creator>dzaeltic</dc:creator>
      <pubDate>Tue, 09 Jun 2026 19:48:24 +0000</pubDate>
      <link>https://dev.to/dzaeltic/key-python-cybersec-libraries-3603</link>
      <guid>https://dev.to/dzaeltic/key-python-cybersec-libraries-3603</guid>
      <description>&lt;p&gt;In this blog, I'm going to briefly break down 4 libraries commonly used in Cyber Security. It's an area I am interested to do more research in. I may make another blog about this field. Now, the libraries I will be exploring are: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://scapy.readthedocs.io/en/latest/introduction.html" rel="noopener noreferrer"&gt;scapy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://requests.readthedocs.io/en/latest/" rel="noopener noreferrer"&gt;requests&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://cryptography.io/en/latest/" rel="noopener noreferrer"&gt;cryptography&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Python has even more open-source software(OSS) libraries that suit many cybersecurity needs. The community is active, meaning the tools are ever-growing. Some use cases for this may be networking, cryptography, data serialization, machine learning, math, etc.&lt;/p&gt;

&lt;p&gt;One advantage of having these libraries is that it abstracts away a lot of the complexity behind the scenes and lets professionals put out scripts in only a few lines. This allows counter-attacks to happen ASAP. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SCAPY&lt;/strong&gt;&lt;br&gt;
Scapy is a tool used to "send, sniff, dissect, and forge network packets... Scapy can easily handle most classical tasks like scanning, tracerouting, probing, unit tests, attacks or network discovery." &lt;/p&gt;

&lt;p&gt;A packet is just a small portion of a larger piece of data. They are relevant to cybersecurity because they have information about the source &lt;em&gt;and&lt;/em&gt; destination IP address. They can also be manipulated to form malicious attacks, overwhelming a system with too many packets (DDoS) or exploiting a system's vulnerabilities. This is a versatile tool because of its ability for surveillance and attacks alike. &lt;/p&gt;

&lt;p&gt;Scapy prides itself in this versatility. Apparently, "90% of network probing tools can be rewritten in 2 lines of Scapy."&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="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sr1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;IP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;www.slashdot.org&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nc"&gt;ICMP&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;XXXXXXXXXXX&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;Begin&lt;/span&gt; &lt;span class="n"&gt;emission&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="n"&gt;Finished&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="n"&gt;send&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="n"&gt;packets&lt;/span&gt;&lt;span class="p"&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;Received&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="n"&gt;packets&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;got&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="n"&gt;answers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;remaining&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="n"&gt;packets&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IP&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="il"&gt;4L&lt;/span&gt; &lt;span class="n"&gt;ihl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="il"&gt;5L&lt;/span&gt; &lt;span class="n"&gt;tos&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mh"&gt;0x0&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;39&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;15489&lt;/span&gt; &lt;span class="n"&gt;flags&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;frag&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="il"&gt;0L&lt;/span&gt; &lt;span class="n"&gt;ttl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;42&lt;/span&gt; &lt;span class="n"&gt;proto&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;ICMP&lt;/span&gt;
 &lt;span class="n"&gt;chksum&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mh"&gt;0x51dd&lt;/span&gt; &lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;66.35&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;250.151&lt;/span&gt; &lt;span class="n"&gt;dst&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;192.168&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;5.21&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;''&lt;/span&gt; &lt;span class="o"&gt;|&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ICMP&lt;/span&gt; &lt;span class="nb"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;echo&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;reply&lt;/span&gt;
 &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="n"&gt;chksum&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mh"&gt;0xee45&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mh"&gt;0x0&lt;/span&gt; &lt;span class="n"&gt;seq&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mh"&gt;0x0&lt;/span&gt; &lt;span class="o"&gt;|&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Raw&lt;/span&gt; &lt;span class="n"&gt;load&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;XXXXXXXXXXX&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
 &lt;span class="o"&gt;|&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Padding&lt;/span&gt; &lt;span class="n"&gt;load&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="se"&gt;\x00\x00\x00\x00&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&amp;gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;show&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="n"&gt;IP&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;---&lt;/span&gt;
&lt;span class="n"&gt;version&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="il"&gt;4L&lt;/span&gt;
&lt;span class="n"&gt;ihl&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="il"&gt;5L&lt;/span&gt;
&lt;span class="n"&gt;tos&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0x0&lt;/span&gt;
&lt;span class="nb"&gt;len&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;39&lt;/span&gt;
&lt;span class="nb"&gt;id&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;15489&lt;/span&gt;
&lt;span class="n"&gt;flags&lt;/span&gt;     &lt;span class="o"&gt;=&lt;/span&gt;
&lt;span class="n"&gt;frag&lt;/span&gt;      &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="il"&gt;0L&lt;/span&gt;
&lt;span class="n"&gt;ttl&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;
&lt;span class="n"&gt;proto&lt;/span&gt;     &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ICMP&lt;/span&gt;
&lt;span class="n"&gt;chksum&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0x51dd&lt;/span&gt;
&lt;span class="n"&gt;src&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;66.35&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;250.151&lt;/span&gt;
&lt;span class="n"&gt;dst&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;192.168&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="mf"&gt;5.21&lt;/span&gt;
&lt;span class="n"&gt;options&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;''&lt;/span&gt;
&lt;span class="o"&gt;---&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="n"&gt;ICMP&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;---&lt;/span&gt;
   &lt;span class="nb"&gt;type&lt;/span&gt;      &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;echo&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;reply&lt;/span&gt;
   &lt;span class="n"&gt;code&lt;/span&gt;      &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
   &lt;span class="n"&gt;chksum&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0xee45&lt;/span&gt;
   &lt;span class="nb"&gt;id&lt;/span&gt;        &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0x0&lt;/span&gt;
   &lt;span class="n"&gt;seq&lt;/span&gt;       &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mh"&gt;0x0&lt;/span&gt;
&lt;span class="o"&gt;---&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="n"&gt;Raw&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;---&lt;/span&gt;
      &lt;span class="n"&gt;load&lt;/span&gt;      &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;XXXXXXXXXXX&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;---&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="n"&gt;Padding&lt;/span&gt; &lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;---&lt;/span&gt;
         &lt;span class="n"&gt;load&lt;/span&gt;      &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="se"&gt;\x00\x00\x00\x00&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Scapy runs from the terminal, so it is very quick to run prompts, and variables that are made (like p in this example) get saved to your current session.&lt;/p&gt;

&lt;p&gt;As we can see above, the sr1 function sends a packet and receives the first answer. p.show() allows us to display details about that packet. By default, it will show everything, but the display can be filtered.&lt;/p&gt;

&lt;p&gt;Scapy pairs well with a packet analyzer software like wireshark, so you can view packets moving on your network live.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;REQUESTS&lt;/strong&gt;&lt;br&gt;
Requests is simply a tool to make http requests. It is designed to be highly readable and quick to implement. "There’s no need to manually add query strings to your URLs, or to form-encode your POST data. Keep-alive and HTTP connection pooling are 100% automatic." This lets requests get made in a single line.&lt;/p&gt;

&lt;p&gt;All instantiations of Request will have access to many methods like text, headers, encoding, json, etc., so viewing certain parts of the response are easy. &lt;/p&gt;

&lt;p&gt;Here is an example of making a basic request and viewing it's url:&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;payload&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;key1&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;value1&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;key2&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&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;value2&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;value3&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]}&lt;/span&gt;

&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&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;https://httpbin.org/get&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;payload&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;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="c1"&gt;# https://httpbin.org/get?key1=value1&amp;amp;key2=value2&amp;amp;key2=value3
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Requests also has a Session class, so we can save some params or cookies to be used across all request made in that session.&lt;/p&gt;

&lt;p&gt;Here is an example from Ayushman Dubey in an &lt;a href="https://tryhackme.com/resources/blog/python3-requests" rel="noopener noreferrer"&gt;article&lt;/a&gt; from TryHackMe where data is extracted from an IP using the requests library:&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="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;  &lt;span class="c1"&gt;# Need to parse recieved data
&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;iplookup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;public_ip&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&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;http://ip-api.com/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;public_ip&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status_code&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="c1"&gt;# If success 
&lt;/span&gt;        &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loads&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# Load the recieved data in json object
&lt;/span&gt;        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&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="c1"&gt;# This will iterate over dictionary
&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;{}:{}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&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="c1"&gt;# If error occurs
&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;Error Occured while making request&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__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;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Enter IP: &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nf"&gt;iplookup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;except&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;Error Occured!&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;strong&gt;CRYPTOGRAPHY&lt;/strong&gt;&lt;br&gt;
Data encryption is important for good security, and this library is perfect for that. It offers many encryption formulas, although, the developers do not suggest using the "hazmat" level of encryption without a good understanding first.&lt;/p&gt;

&lt;p&gt;The encryption is made with a key that the key holder must keep safe, as that is their method of decrypting the hidden data. It looks like this:&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="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;cryptography.fernet&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Fernet&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Fernet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;generate_key&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Fernet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;my deep dark secret&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;
&lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;...&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;decrypt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="sa"&gt;b&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;my deep dark secret&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"The result of this encryption is known as a 'Fernet token' and has strong privacy and authenticity guarantees."&lt;/p&gt;

&lt;p&gt;More specifications about how data is encrypted with Fernet can be found &lt;a href="https://github.com/fernet/spec/blob/master/Spec.md" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;These are very basic libraries, but there are more advanced ones for doing things like pen-testing and ethical hacking! If you're interested in that, I would check out &lt;a href="https://docs.pwntools.com/en/stable/" rel="noopener noreferrer"&gt;pwntools&lt;/a&gt;. This is a very broad library with a wide range of use, so I didn't touch on it this blog. It deserves its own blog. &lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>opensource</category>
      <category>python</category>
      <category>security</category>
    </item>
    <item>
      <title>Automation in Python</title>
      <dc:creator>dzaeltic</dc:creator>
      <pubDate>Mon, 01 Jun 2026 12:47:29 +0000</pubDate>
      <link>https://dev.to/dzaeltic/automation-in-python-874</link>
      <guid>https://dev.to/dzaeltic/automation-in-python-874</guid>
      <description>&lt;p&gt;This is a basic introduction to scripting and automation. After introducing these topics and explaining why Python should be the go to tool for these types of tasks, I'll show some code examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Script?
&lt;/h2&gt;

&lt;p&gt;I want to bring this up because when I started researching about automation, I went into it coupling the idea of scripting and automation together, and I didn't even really know why. When I really started to understand what a script actually is, I understood why it is fundamental for anything automated with code. They are the recipes that set up your robot cook to be able to start cooking.&lt;/p&gt;

&lt;p&gt;A script is really just a focused piece of code that does something. For example, it can convert a large data sample into a readable report for you. It could take an email template and a list of recipients and send them all a personalized email. It can convert all the images in a specific file to jpegs. You get the idea. Then, chain scripts together to get more complex outputs/functionality and schedule them to run without needing human input; now you're automating!&lt;/p&gt;

&lt;p&gt;What made this all so confusing to me at first was figuring out the difference between a programming language and a scripting language. The difference isn't hugely important in the context of this blog except that scripting is much easier in languages considered "scripting languages" like JavaScript or Python.&lt;/p&gt;

&lt;p&gt;Cool, now that we understand what a script is; let's give our robot cook some recipes, so it can start cooking.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Automation?
&lt;/h2&gt;

&lt;p&gt;Let's say I'm the head chef of a brand new startup food truck. The opening was rushed, so the menu is really small. I want time for R&amp;amp;D so I can expand the menu, but my truck's popularity is really starting to pick up. I don't have enough time on my hand! This is the core concept behind why we automate. When we can offload menial tasks to our machine it frees up two of our most precious resources: time and mental capacity. If I had a robot cook to operate my fryers automatically, I'd declutter my mind to have better connections with my customers &lt;em&gt;and&lt;/em&gt; have time to R&amp;amp;D new menu items while we're slow! Also, my new robot is probably a better fry cook than even me. He never messes up his timers!&lt;/p&gt;

&lt;p&gt;Okay, that was a pretty niche example; I know, so let's take a look at some more tangible ones if you're still not seeing how powerful this could be for you. I can give all my employees key cards to login, automating security checks and what they have access to on an individual level. I can  automatically scrape large customer data sets and monitor who my best customers are. Maybe even give them a promo discount. I could even automate a portion of my paycheck to go straight into savings when I get paid. The list goes on.&lt;/p&gt;

&lt;h2&gt;
  
  
  So, Why Python?
&lt;/h2&gt;

&lt;p&gt;&lt;u&gt;Interaction with Operating System&lt;/u&gt;&lt;br&gt;
Scripts being run in the terminal and modules like os, sys, and shutil let Python touch system files, settings and OS easily. &lt;/p&gt;

&lt;p&gt;&lt;u&gt;Extensive Library&lt;/u&gt;&lt;br&gt;
The list of available packages that help with automation are massive. This makes automating tasks related to data science, web scraping, web browsing, file management etc. very easy.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Ease of Access&lt;/u&gt;&lt;br&gt;
Python is fast to write and easy to understand, saving developers time and getting scripts up and running quickly. This is especially useful in fields like cybersecurity where counter-attacks need to launch as soon as possible.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;The Ecosystem&lt;/u&gt;&lt;br&gt;
This is the way that it developed over time. JavaScript was built around web design, and its ecosystem reflects that. Python was built around being easy and fast to write, and it shows. The frameworks available for it are diverse and powerful, ranging from web development to science to game development to security. As time goes on, people will keep pushing the general purpose uses of Python even further.&lt;/p&gt;
&lt;h2&gt;
  
  
  Example Time
&lt;/h2&gt;

&lt;p&gt;So, hopefully I've opened you're eyes to why Python is an amazing tool for automation. Let's look at what it might look like practically.&lt;/p&gt;

&lt;p&gt;This a script written by Devesh Tiwari and Josh Vinson. You can find the link to the github repository &lt;a href="https://github.com/AIdevol/Automated-File-Organizer/tree/main" rel="noopener noreferrer"&gt;here&lt;/a&gt;. I chose this example because it shows how easily Python scripts can touch system files. It isn't really &lt;em&gt;automated&lt;/em&gt;, but it is a really good example of a type of script that Python might excel in over JavaScript. If we hooked this up to happen whenever a large folder system gets added to my computer, that would be automating it.&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="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;shutil&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;categorize_file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filepath&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;extension&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;splitext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filepath&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;categories&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;.jpg&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;images&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;.png&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;images&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;.pdf&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;documents&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;.docx&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;documents&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;.mp4&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;videos&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;.avi&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;videos&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;.mkv&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;videos&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;.exe&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;apps&lt;/span&gt;&lt;span class="sh"&gt;"&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;categories&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="n"&gt;extension&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;other&lt;/span&gt;&lt;span class="sh"&gt;"&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;create_folders&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;directory&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;makedirs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;directory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;images&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;exist_ok&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;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;makedirs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;directory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;documents&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;exist_ok&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;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;makedirs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;directory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;videos&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;exist_ok&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;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;makedirs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;directory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;other&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;exist_ok&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;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;makedirs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;directory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;apps&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;exist_ok&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="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;sort_files&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source_directory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target_directory&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;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;files&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source_directory&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;filename&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;files&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;filepath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;file_category&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;categorize_file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;target_path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target_directory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;file_category&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;shutil&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;copy2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filepath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target_path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;file_date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromtimestamp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getmtime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;filepath&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

                &lt;span class="c1"&gt;# Replace colons to avoid invalid filename errors
&lt;/span&gt;                &lt;span class="n"&gt;sanitized_date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;file_date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isoformat&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;:&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;-&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;new_filename&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;sanitized_date&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;-&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

                &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target_path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dirname&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target_path&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;new_filename&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
            &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&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="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Error moving &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;filepath&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&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;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;source_directory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Sorry to bother you Lord Vinson, but I&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ll need the source directory:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;target_directory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Sorry to bother you once again Lord Vader, but I&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ll need the destination directory:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="nf"&gt;create_folders&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target_directory&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;sort_files&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source_directory&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target_directory&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;File organization completed!&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__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;__main__&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The script takes an input target file path and destination file path. It then sorts them by what type of file they are, and copies them over to the new destination. It also prepends the date and time that they were moved to the file name. One thing to note about this script is that it makes copies of the original files and does not delete them, so this is a great script if you wanted to export a folder but keep them how they are on your machine.&lt;/p&gt;

&lt;p&gt;Automating things is easier than ever. The are so many free tools available for pretty much anything you can think of with Python. I encourage you to do some more research on this topic if you found this interesting. Here are some good resources to get you started:&lt;/p&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;div class="c-embed__content"&gt;
        &lt;div class="c-embed__cover"&gt;
          &lt;a href="https://zapier.com/blog/python-automation/" class="c-link align-middle" rel="noopener noreferrer"&gt;
            &lt;img alt="" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.ctfassets.net%2Flzny33ho1g45%2FO97hZQ1aOEmlyKFuO2IuD%2F8f6eb4703d8b219940fd89be5bf9f694%2Fpython-hero.jpg" height="401" class="m-0" width="800"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="c-embed__body"&gt;
        &lt;h2 class="fs-xl lh-tight"&gt;
          &lt;a href="https://zapier.com/blog/python-automation/" rel="noopener noreferrer" class="c-link"&gt;
            Python automation: 9 scripts to automate workflows | Zapier
          &lt;/a&gt;
        &lt;/h2&gt;
          &lt;p class="truncate-at-3"&gt;
            Learn how to automate tasks with Python and boost your productivity. Try out these Python automation scripts for web scraping, data processing, and more.
          &lt;/p&gt;
        &lt;div class="color-secondary fs-s flex items-center"&gt;
            &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.zapier.com%2Fzapier%2Fimages%2Ffavicon.ico" width="192" height="192"&gt;
          zapier.com
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;



&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;div class="c-embed__content"&gt;
      &lt;div class="c-embed__body flex items-center justify-between"&gt;
        &lt;a href="https://www.datacamp.com/tutorial/python-automation" rel="noopener noreferrer" class="c-link fw-bold flex items-center"&gt;
          &lt;span class="mr-2"&gt;datacamp.com&lt;/span&gt;
          

        &lt;/a&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;



&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
    &lt;div class="c-embed__content"&gt;
        &lt;div class="c-embed__cover"&gt;
          &lt;a href="https://www.advsyscon.com/blog/it-automation-with-python/" class="c-link align-middle" rel="noopener noreferrer"&gt;
            &lt;img alt="" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.advsyscon.com%2Fwp-content%2Fuploads%2Fpython-automation-768x520.png" height="520" class="m-0" width="768"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="c-embed__body"&gt;
        &lt;h2 class="fs-xl lh-tight"&gt;
          &lt;a href="https://www.advsyscon.com/blog/it-automation-with-python/" rel="noopener noreferrer" class="c-link"&gt;
            IT Automation with Python | ActiveBatch BlogIT Automation with Python | ActiveBatch Blog
          &lt;/a&gt;
        &lt;/h2&gt;
          &lt;p class="truncate-at-3"&gt;
            Learn More about IT Automation with Python and how it can help you and your company streamline repetitive workflows and increase efficiency.
          &lt;/p&gt;
        &lt;div class="color-secondary fs-s flex items-center"&gt;
            &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.advsyscon.com%2Fwp-content%2Fuploads%2Ffavicon.ico" width="48" height="48"&gt;
          advsyscon.com
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;



</description>
    </item>
    <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://dev.to/dzaeltic/python-as-a-javascript-dev-51jm</link>
      <guid>https://dev.to/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://dev.to/dzaeltic/what-makes-a-good-codebase-1a2h</link>
      <guid>https://dev.to/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://dev.to/dzaeltic/jquery-53jk</link>
      <guid>https://dev.to/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>
