<?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: Deeter Neumann</title>
    <description>The latest articles on DEV Community by Deeter Neumann (@drn19).</description>
    <link>https://dev.to/drn19</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2084177%2F6a746886-9f62-45cf-a70c-4a919d0c4894.png</url>
      <title>DEV Community: Deeter Neumann</title>
      <link>https://dev.to/drn19</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/drn19"/>
    <language>en</language>
    <item>
      <title>File Mover with pathlib</title>
      <dc:creator>Deeter Neumann</dc:creator>
      <pubDate>Tue, 17 Sep 2024 20:51:21 +0000</pubDate>
      <link>https://dev.to/drn19/file-mover-with-pathlib-4ig4</link>
      <guid>https://dev.to/drn19/file-mover-with-pathlib-4ig4</guid>
      <description>&lt;p&gt;The pathlib module in the Python standard library is no doubt powerful - maybe more powerful than what I was ready for. And this showed as I first worked with pathlib on several labs and projects focused on printing file names in the terminal, changing file names, and moving files. But working with pathlib on the aforementioned tasks helped to become more comfortable with it's functionality. One specific, and rather brief script, I completed with pathlib was a file mover.&lt;/p&gt;

&lt;p&gt;My file mover script utilized pathlib (import pathlib) to create a Path object and assign it to a variable (folder = pathlib.Path(some directory). In my project, "some directory" is a directory for a specific folder on my computer. I then created a new Path object, assigned it to the variable "new_path", where I intended to move specific files to (new_path = pathlib.Path(some directory/screenshots). Additionally, using the .mkdir() method, if "some directory/screenshots" did not already exist, it will get created (new_path.mkdir(exist_ok=True)). The "exist_ok=True" argument here is necessary to avoid a "FileExistsError" if the directory already exists.&lt;/p&gt;

&lt;p&gt;The next block of my code utilizes a for loop to iterate through each file within the directory defined by the variable "folder" (for filepath in folder.iterdir():). A conditional statement is then nested in the for loop to identify the file type I am interested in moving. This line of code uses the ".suffix" attribute to find files with a specific extension. In this project, I identify screenshots with the ".png" extension (if filepath.suffix == ".png"). If the if statement evaluates as True, meaning the file is indeed a screenshot, the script uses the ".joinpath()" method to create a new destination path into the "some directory/screenshots" where the .png-containing file gets stored. This new destination path was stored in the variable "new_filepath" (new_filepath = new_path.joinpath(filepath.name)). Lastly, the .replace() method is used on filepath to perform the actual move of the ".png" file to the new directory (filepath.replace(new_filepath)).&lt;/p&gt;

&lt;p&gt;This project was a great example of the automation that can be achieved with Python. As I become more familiar with using the pathlib module, I am sure I will find new uses for it that will simplify the more mundane tasks I perform on my computer.&lt;/p&gt;

</description>
      <category>beginners</category>
    </item>
    <item>
      <title>Simple Command Line Dungeons and Dragons</title>
      <dc:creator>Deeter Neumann</dc:creator>
      <pubDate>Tue, 17 Sep 2024 18:27:27 +0000</pubDate>
      <link>https://dev.to/drn19/simple-command-line-dungeons-and-dragons-59gj</link>
      <guid>https://dev.to/drn19/simple-command-line-dungeons-and-dragons-59gj</guid>
      <description>&lt;p&gt;As a participant in a Coding Nomads bootcamp, one of the early projects in the Python course is a simple Dungeon and Dragons command line game. The objective: find a sword and slay a dragon. The command line game is driven by user input (responding to presented binary choices; e.g., yes / no, fight / safety). In addition to user input, flag variables are essential in the code to both keep track of where the player is located in the game (i.e., player_pos = "c" ("c" = corridor; "l" = left (empty) room; "r" = right (dragon) room), whether the player has the sword, and finally, whether the dragon is alive. The sword is initially hidden in the empty room on the left, and is tracked via the flag "has_sword." Initially set to "False", when the sword is looked for and found, the flag switches to "True". The status of the dragon is tracked via the Boolean flag variable, "dragon_dead = False". In addition to tracking the dragon's status, this Boolean flag also keeps the player within a while loop where the player can move between the corridor, the left room, and the right room. In order to claim victory in this game, the player must find and take the sword, then enter the dragon's lair, and chose to fight it. Alternatively, if the player choses to fight the dragon without the sword, they will meet their demise in the command line game. Once the dragon_dead Boolean flag variable flips to "True", the code exits from the while loop, and the player can claim victory.&lt;/p&gt;

&lt;p&gt;Again, this was an early in my Python learning, but the project emphasized the utility that flag variables offer in coding. Additionally, to get the script to operate fluidly, nested loops had to be constructed and carefully place to ensure the player could not backtrack and repeat previous actions they already took.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>python</category>
    </item>
  </channel>
</rss>
