Python Shortcuts That Save Me Hours Weekly

Python Shortcuts That Save Me Hours Weekly

I never considered Python as a “personal assistant,” but I discovered it could boost my daily efficiency. By automating mundane tasks and organizing files, Python became my secret productivity tool.

Automating File Organization
My downloads folder was once a chaotic mess. A simple Python script resolved that.

“`python
import os, shutil
downloads = “C:/Users/Me/Downloads”
folders = {“Images”: [“.jpg”, “.png”], “Docs”: [“.pdf”, “.docx”], “Code”: [“.py”, “.js”]}
for file in os.listdir(downloads):
for folder, extensions in folders.items():
if file.endswith(tuple(extensions)):
shutil.move(os.path.join(downloads, file), os.path.join(downloads, folder, file))
“`

Now, my files organize themselves into orderly folders automatically.

Quick Daily Journal Logger
Instead of opening a notepad every evening, I use Python to jot down my thoughts in a daily log.

“`python
from datetime import datetime
with open(“journal.txt”, “a”) as f:
f.write(f”{datetime.now()} – Today I coded and learned.n”)
“`

It’s simple, yet journaling became an effortless habit.

Instant Weather Updates
Checking weather apps was time-consuming, so I created a quick script to ping an API.

“`python
import requests
city = “London”
api_key = “your_api_key_here”
url = f”http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}”
data = requests.get(url).json()
print(f”Weather: {data[‘weather’][0][‘description’]}, Temp: {data[‘main’][‘temp’] – 273.15:.2f}°C”)
“`

One execution, and I instantly know if I need an umbrella.

Automating Emails
Instead of composing repetitive “status update” emails, Python handles it for me.

“`python
import smtplib
server = smtplib.SMTP(“smtp.gmail.com”, 587)
server.starttls()
server.login(“me@gmail.com”, “password”)
server.sendmail(“me@gmail.com”, “boss@gmail.com”, “Subject: UpdatennWork done for today!”)
server.quit()
“`

It saves valuable minutes from my daily routine.

Tracking My Habits
I was curious about my exercise consistency, so I built a logger.

“`python
def log_habit(habit):
with open(“habits.csv”, “a”) as f:
from datetime import date
f.write(f”{date.today()},{habit}n”)
log_habit(“Exercise”)
“`

Later, I visualized the data in Python with Matplotlib.

Scraping News Headlines
Instead of endless scrolling, I gather just the headlines with a Python script.

“`python
import requests
from bs4 import BeautifulSoup
url = “https://news.ycombinator.com”
soup = BeautifulSoup(requests.get(url).text, “html.parser”)
for title in soup.select(“.titleline a”):
print(title.text)
“`

This keeps me informed without spending hours online.

Why It Works
Python isn’t just for developers. It’s like a Swiss Army knife for time. The more I automated trivial tasks, the more mental energy I conserved for meaningful work.

A message from our Founder
Hey, Sunil here. I wanted to take a moment to thank you for reading until the end and for being a part of this community.

Did you know that our team run these publications as a volunteer effort to over 3.5m monthly readers? We don’t receive any funding, we do this to support the community. ❤️

If you want to show some love, please take a moment to follow me on LinkedIn, TikTok, Instagram. You can also subscribe to our weekly newsletter.

And before you go, don’t forget to clap and follow the writer!

Leave a Reply

Your email address will not be published. Required fields are marked *