Python Scripting -a superpower for non-programmers.

Photo by u/5ubv3rsion on Reddit

Introduction to Python

What Is Python?

Why Python?

  • Python is very easy to get into and start coding. It has a syntax very similar to normal English.
  • A large number of communities and books are available to support Python developers.
  • Python is a general-purpose programming language. Hence it can be used to make a variety of applications.

Python is the one programming language to rule them all.

Photo by xkcd

Why Python Scripting?

When some task is monotonous and repeating in nature: Script it in Python.

Python Scripts to Automate Tasks

Automate Updates in Excel Sheets

import openpyxl as xl
wb = xl.load_workbook('python-spreadsheet.xlsx')
sheet = wb['Sheet1']
for row in range(2, sheet.max_row + 1):
cell = sheet.cell(row, 3)
corrected_price = float(cell.value.replace('$','')) % 10
corrected_price_cell = sheet.cell(row, 4)
corrected_price_cell.value = corrected_price
Data entry is very monotonous

Sending Emails

import getpass                                                                                              import smtplib                                                                         HOST = “smtp.gmail.com”                                                                                      PORT = 465 
username = “youremail@gmail.com” password = getpass.getpass(“Enter your gmail password“)
server = smtplib.SMTP_SSL(HOST, PORT)
server.login(username, password) server.sendmail(“from@domain.com”, “to@domain.com”, “Hello There!”,)
server.quit()

Speech-based Diary

import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:
print("say something")
audio = r.listen(source)
try:
print("Your text: "+r.recognize_google(audio))
except:
pass

Real-life examples of Python Scripting

  • Routinely download files from a website
  • Share Prices Tracker / Notifier
  • Chatbot
  • Filling Online Forms

Ideas for automating tasks

  • File Management- For example deleting the files from recycle bin periodically.
  • Reminders/Notifiers for social media- You can write a script that will inform you if your favourite social media influencer /page has posted something.
  • Automating your daily desktop routine- Checking your emails, messages and tasks assigned to you on Slack? You can write a script that will show you all of these things in one place.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store