How Do I Actually Build Something With Python?

I've been programming in Python for a while now. I'm familiar with all the basic functionalities and have been working on algorithms for a while as well. My question is, how do I actually build something solid with Python (say, an application, or a program that automatically replies to all my emails with a pre-written message)? I simply have no clue how to do that. I'm only familiar with the "logic" of Python, but I can't "build" anything with it. Where do I start? What do I learn?

89 comments · 98% upvoted · other discussions

comments

[deleted]

[deleted]

[deleted]

This is the best way - break down projects into smaller more achievable tasks, and then bring them all together at the end (this is the most fun part imo!)

[deleted]

I think you misspelled infuriating. The most infuriating part.

skellious

Can we pin this or something? It's really good.

FifthRendition

Would you say that mapping out your program is the most important or top 3 of the important things to do?

[deleted]

[deleted]

FifthRendition

Good insight, thank you for sharing!

Empyrealist

/u/SpiritedExit0, to add on to /u/Meshi26's excellent response - these are the outlines of proper 'project management'. This would be an excellent time to learn-up on PM and the tools you can use to make yourself more effective at it. This will help you identify goals, steps of achievement, and milestones. Planning-out and breaking these things down into manageable bits can go a long way to help realize what it is you need to do to achieve your goal.

Bonus it also helps you start tracking and budgeting your time, which can be critical as a developer.

This could be a great time to lay the groundwork for a healthy workflow and routine.

Name_Zam37

If only awards were for free, I'd have liked to give you a bunch of them.

Evo1uti0nX

I believe you get a free award to give away now, actually.

Name_Zam37

You're right, but that I've spent already.

BountyApe

Thanks a LOT for this! May god bless you with seven children

[deleted]

I have a question how can I make python fill blanks in a program I don't know how to search on net

bjone6

I think u/Meshi26's advice is spot on. I struggled with the same thing while stuck in tutorial hell for programming. I decided that I was going to build my own digital assistant like Jarvis from the Iron Man movies and comics. Then I thought about all the hundreds of tasks that I would want and then kept breaking those tasks down. Then I started building real things. I have a small YouTube showing off some of the tasks that Python can do.

https://www.youtube.com/channel/UCW34Ghe9-_TCA5Vy3-Agfnw

evnomics

I just watched a couple of your videos. Love your topic selection.

Free feedback:

1) Get to the programming faster and sprinkle the commentary along the way. We can find out that you paid for alpha vantage when you get to calling the API, or that Zillow has radius restrictions after seeing an API response with neighborhood data.

2) Tell us what you're trying to accomplish and then bring us along. Why do you care about the zestimate for your rental property? Why do you care about stock data?

3) That's as far as I got in the videos. And I didn't see a single line of code, just a browser showing a web page.

Hope it helps!

bjone6

I appreciate the feedback. I was trying to imitate the bigger Python YouTubers, but you're suggestions are spot on for me just starting out.

evnomics

In this video he runs a script in just 18 seconds: https://youtu.be/k9TUPpGqYTo

You do you, only you can.

bjone6

Right. That's the second video in a tutorial series, where most of the talking was done in the first video of that playlist and/or at the start of his previous tutorial series. This guy has almost as many subscribers but more viral videos and, in this video, doesn't start coding until 6 minutes. https://www.youtube.com/watch?v=-MHhA-Y3DSk

evnomics

Great video, different style.

If you want to make story videos, do what that guy did and open with a strong setup.

"Ok here's the challenge, can I write a program that trades stocks for me, and how much money can I make in a week?"

Those are two different video styles. Both good, but somewhat incompatible.

I like to think of them as, "how did you do that?" and "how can I do this?"

Corey makes the latter, and teaches a ton along the way.

The other guy makes the former.

Different audience intent, different video format.

Edit: as a side note, you can get a lot more viewers early on doing the tutorials, because people are searching for those things. You can more total viewers doing the story format, but it's harder to get going.

Put differently, tutorials are the fastest way to 100k views, and stories are the fastest way to 100m views.

bjone6

Agreed. I don't know enough to do tutorials though. I'd hate to pass on horrible coding principles to the world. I have no formal training and I'm completely self taught. But, I brute force my way through things and figure them out and then make a video. Thanks for the feedback though. I will definitely implement some of your recommendations in this weekend's video.

evnomics

There's a great workaround for that, which is starting each video title with "I". As in, "I Coded A Trading Bot And Gave It $1000 To Trade!"

Example, "I Wrote A Python Script To Track My Property Value Using The Zillow API"

Now you're off the hook. You didn't say you're an expert, you said that you did it. And the only proof needed is doing it.

It satisfies the tutorial requirement of being searchable and step by step, but it removes any need for credibility beyond actually completing the task.

You're not saying it's the best way or even a good way, but it worked for you and you're sharing it.

Does that help?

I'm genuinely learning how to communicate strategy better, so any feedback is appreciated.

evnomics

Step 1: Buy a raspberry pi.

Step 2: Write a script that does something useful to you (download rss feeds, convert an html table into a csv file, etc.)

Step 3: Put the script on the pi and schedule it using "crontab -e".

Step 4: Make the output easier to access by adding a flask/fastapi server.

Edit: don't underestimate the value of a basic script running on a raspberry pi. You can build a $500/month micro-SaaS business that way.

iTAMEi

Very interesting. Any advice with starting a micro-SaaS business?

evnomics

The stupidest problems are the best problems. They're easier to solve and people think they're too stupid to be worth solving. Less competition from programmers who like working on cool projects, and less competition from VC money looking for unicorns.

I prefer projects that remove headaches. That way the client is paying me for nothing. Which is less of a hassle than when they're paying for something. They keep paying as long as the headache stays away.

There seems to be a sweet spot in the $49 to $199 per month price range.

Don't make the mistake of trying to build a company. It took me two years of feeling guilty for not trying to grow revenue to realize that if I don't want to grow it, I don't have to.

There's nothing wrong with earning an extra $500/mo for having written a script.

NimbleBodhi

That's really interesting, do you have any examples or links or these kinds of services?

evnomics

Zapier's list of most popular zaps is a great place to start.

The more money people have, the more they tend to want someone to call instead of somewhere to login.

So turning a zap into a micro-SaaS company is a great start.

I'll give you a free one: a service that auto saves attachments from emails to an API accessible server.

NimbleBodhi

Thanks, I'm gonna look into this.

mrrippington

Thank you for sharing this :) I will get a pi zero to build an app.

iTAMEi

Cheers, really got me thinking. Will have to buy a raspberry Pi!

> So turning a zap into a micro-SaaS company is a great start.

From the customers point of view, why pay for something you can already get on Zapier?

evnomics

From the customers point of view, why pay for something you can already get on Zapier?

For the same reason programmers use Zapier for tasks they could setup themselves in a few lines of Python. Convenience, speed, and maintenance.

Why would I spend 5 hours attempting to set something up using a service I've never used before when I could just pay you $49/mo and have it solved for me?

And if something changes, I just tell you and you fix it.

People also buy food at restaurants for the same reasons.

Can technically and can economically are vastly different.

iTAMEi

Sounds great. Thanks for the advice.

So from a business point of view, how do you go out actually finding customers without scaling and involving marketing etc? Good old fashioned talking to people?

Am I right that the business model here is to find a couple of people willing to pay, get it set up and then just enjoy having a small amount of residual income?

It is very easy to start thinking up ideas and then find there are tonnes of very well made existing options already at it.

Cheers

evnomics

It is very easy to start thinking up ideas and then find there are tonnes of very well made existing options already at it.

This is what makes it so hard to actually follow through.

But think about how many restaurants there are, how many clothing stores there are, and how many domain name registrars there are.

The important thing is not what the market wants, but what your market wants.

And B2B is a great place to find a market.

Emails and spreadsheets are the everyday tools in corporate land. Build something compatible with those tools instead of replacing those tools.

Also, if you want to list all your questions and concerns, I may be able to do a more thorough write-up later.

iTAMEi

Cheers man that would be super cool, really appreciate sharing your thoughts. I’ll do some brainstorming and get back to you!

r-_-mark

I would love to know how to turn a product into a Micro-SaaS how would I show my product and get paid for and how to market it Basically the business side of it

evnomics

Start with a person with a problem they're willing to pay for, build a minimal, low maintenance solution for their problem, and you'll have a paying customer from the start. Then find more people with that problem.

Also, read Paul Graham's blog.

a_moss_snake

just read life is short and can tell I'm gonna enjoy this blog, thanks for the suggestion.

evnomics

This is one of my favorites: http://www.paulgraham.com/taste.html

ivosaurus
[deleted]

And how secure can a novice expect such a service to be after building it?

JohnnyJordaan

https://automatetheboringstuff.com/2e/ is a good resource to learn how to build real life automation scripts.

Whom Is This Book For?

Software is at the core of so many of the tools we use today: nearly everyone uses social networks to communicate, many people have internet-connected computers in their phones, and most office jobs involve interacting with a computer to get work done. As a result, the demand for people who can code has skyrocketed. Countless books, interactive web tutorials, and developer boot camps promise to turn ambitious beginners into software engineers with six-figure salaries.

This book is not for those people. It’s for everyone else.

On its own, this book won’t turn you into a professional software developer any more than a few guitar lessons will turn you into a rock star. But if you’re an office worker, administrator, academic, or anyone else who uses a computer for work or fun, you will learn the basics of programming so that you can automate simple tasks such as these:

-Moving and renaming thousands of files and sorting them into folders
-Filling out online forms—no typing required
-Downloading files or copying text from a website whenever it updates
-Having your computer text you custom notifications
-Updating or formatting Excel spreadsheets
-Checking your email and sending out prewritten responses

These tasks are simple but time-consuming for humans, and they’re often so trivial or specific that there’s no ready-made software to perform them. Armed with a little bit of programming knowledge, however, you can have your computer do these tasks for you.

thisduck_

I was going to make the same recommendation. From chapter 11 on its all quite solid ‘do real stuff’ advice. Can’t beat the price tag either.

Metalsoul262

The author has a Udemy course for the same book as well. I'm about halfway though it learning the basics!

[deleted]

Coooll we are in the same zone at the same time

samweep

same zone, same time

martyornot

Every month, you can find a code to access this course for free.

memilanuk

+1 for AtBS!

I've used it to make my life easier through automating a few tasks like downloading a mailing list from Google Sheets to a CSV, after sorting by certain criteria, and to automate downloading a PDF attachment (the newsletter content for the mailing list) from a Gmail account, and renaming it with a consistent format. I've also taken what I learned from those tasks, to automate uploading the PDF file to the WordPress site for a non-profit amateur sports club that I help out with.

About the only part I haven't automated yet is the process of updating the mailing list app we use (MailChimp) from the CSV, and updating and sending out the notifications, also using MailChimp. But it's on the list! ;)

Honestly, I'd say at least half, if not three-quarters, of the questions on /r/learnpython can be addressed simply by referring to AtBS!

v3ritas1989
r-_-mark

I would just recommend PyQT better then tkinter specially if you are coming from a background just like JavaFX Also I got into a lot of hustle to start working with Tkinter in one laptop that I used to work with dunno why though

zurtex

I built a lot of "back end" systems for many years, that would manage processes, move around data, send emails etc.

One day my manager wanted me to build a small log vitalization tool so I learnt Flask and got something basic working and I was pretty happy with it.

Over time this tool expanded and my manager wanted "it to update without me refreshing but only if it doesn't take you too much time". Okay... So after a little research I found Dash I was able to pick it up in a few days and convince myself it was possible to rewrite my tool with Dash.

After that I just kept building on Dash, and I found it surprisingly satisfying to be able to build tools that people could see and interact with.

r-_-mark

Dash is great Honestly it deserve way more love I sound it way easier then Bokeh

yasoob_python

Hi /u/SpiritedExit0,

Most of the comments here are spot on. You need to break a project down into individual steps. For example, I made a paste bin (a nicer version of https://paste.ubuntu.com/) using Python and Flask a long time ago and that was my first major Python project. These are roughly the steps I took:

  1. I need to make a website so what can I use? Answer was Flask. I looked at the Flask documentation on how to make a basic website
  2. Every paste bin has an input box and a submit button. How do I add those using Flask? Did my research and found out about Jinja and used that to implement the form
  3. I need to save the pastes in a database. Found out about SQLAlchemy and how to use it on top of SQlite to store data
  4. I need to make sure each paste gets a random URL so that no one can easily loop through all the public pastes . Found out about UUIDs and used those for this purpose
  5. I need to limit the posting feature only to the logged in users. Found out about authentication and authorization and learned how to implement that using Flask
  6. Eh it would be nice to allow people to see the differences between two pastes just like `git diff`. Again, did the research, found out about the difflib in Python, and implemented the feature on the website

I also recently wrote a book on Practical Python Projects that I would highly recommend (i might be a bit biased). I wrote the book for precisely the issues that you are having right now. You can learn more about the book on my blog. If you have any questions about my answer or the book I would be more than happy to help. Have a wonderful day! :)

r-_-mark

Difflab that’s new for me So dope python is filled with stuff

r-_-mark

Woah just checked the JPEG blog I was not expecting that’s at all How was your experience writing books ? Publishing / selling, marketing..etc

yasoob_python

It is a big job. Money isn't the primary motivation for me and unless you are self publishing or have a huge following there isn't too much money in it either. But having said that, it is very rewarding when people read and appreciate my writing. If you know enough about something you should definitely write a book. You will learn a ton along the way. My biggest learning from this recent release was that having a deadline does wonders. The amount of work I did in the three days before the deadline was a whole lot more than what I did in the two months prior.

r-_-mark

Thankx a lot mate Deadlines are indeed important felt the same thing when I took a cert ...giving my self a deadline by paying for the exam fees made me indeed go full sicko mode

skullvertex

start by making a (text based) game for someone near you to enjoy.

This is a better starting place than an app because its a small project, fun, easy to discuss with others and get help. Anything more complex at this stage just creates more obsticles.

If you are making a game it means you already know all the "rules" you need to code for and so half of the thinking is already done for you. You know need to code it.

For example, football or soccer sometimes has a penalty shoot out to determine the winner of a football game, if you know how this works you can code it as a text based game (but be sure to use the "random" module to give the game suspense).

other fun projects include a "magic 8 ball fortune teller" or a random name generator.

Goodluck!

[deleted]

Lol I remembered my first actual application is a c++ quiz game then I practiced OOP by building a pokedex app. Programmers learn as they apply tutorial/university lectures into creating systems or else everything will be stuck in theory

mutual_coherence

This is the best advice.

STEM fields can really only be mastered through project based learning.

CaptSprinkls

I second this. The first "real" program I remember making on my own was a turn based game kind of like Pokemon against the computer. It started out as a simple "Quick attack, heavy attack, or heal" for the moves and then the computer would choose a random move. I then went on to make it so you had a character, with stats and equipment and then the same thing would go with the computer and then I even started to add loot. This really helped me to get better with OOP concepts too.

MikeTheWatchGuy

I like that you've got concrete ideas for what you want to build. I always recommend "project based learning" when it comes to programming. Find yourself a project that you're passionate about, then go build it. Sounds simple enough, but of course it's not. But if it's something you really want to make, then you're likely to stick through the difficult parts. It's your idea, your project that's important.... much more than what other people suggest to build.

The automatic reply program should be within reach of your skills. Being able to focus your attention to a specific problem cuts out the often overwhelming rush of tons of questions when you're thinking in a broader "what do I want to make" context.

There was a tutorial posted recently on managing messages using Outlook. It may or may not help your project, just saying that I saw a recent tutorial. Explore the options. Look at the different mail packages that are available.

Deep breathes. Follow the advice about breaking down the problem. That was good advice.

I'm not sure if my program still works, but here's a link to how I made a little reader. It's purpose was to demonstrate showing a GUI window, so some of it may not apply to what you're wanting to achieve.

https://github.com/PySimpleGUI/PySimpleGUI/blob/0f161c399a62c55a85d0afca7bf4925ffd770563/DemoPrograms/Demo_Desktop_Widget_Email_Notification.py

You don't have to "cheat" and look at the whole program. Just look at the packages I used. It appears to work with hotmail and gmail. It only reads email. Sending isn't difficult and there are a good number of tutorials about that.

Stick with the "build things" approach you're instincts are telling you. It's a great way to do it.

TheSpamGuy

I think its one of the bigger challenges for beginners. People think by learning how to write code, they can write programs. But that’s not the case. Learning how to code means you can make computers do what you want. But if you don’t know what you want it to do, you can’t really write good programs. So your next step is to learn how specific technology works. For example how internet works, how machine learning works, how blockchain works etc. once you learn how the technology works, then you can start writing program for that technology. If you want to write program to automate email, your next step is to learn how internet, dns, mail server work.

[deleted]

[deleted]

r-_-mark

How does email got sent ??? Having a basic understanding is indeed required He doesn’t mean know how things works in a low level for sure

[deleted]

[deleted]

r-_-mark

I highly disagree But again I can’t do something (not just in Tech) without having a general idea how it works So maybe it depends on who you are and how you learn

[deleted]

[deleted]

r-_-mark

Interesting maybe you are smarter then what you think I can’t move a step forward without having a bit then a shallow understanding of how something is working

[deleted]

Learn to use GUIs. Tkinter is free, but PyQt is more widely used. You can convert a command line program into a more user friendly interface thereby. There’s a 6 hour course on Youtube that I like quite a bit on tkinter from freecodecamp.org

Se7enLC

It's the same with most other programming language. The inputs and outputs are the hard part. That's why most beginner programming guides are how to build "command-line" applications produce only text and take in only keyboard inputs.

The mechanisms to take in other input and produce other output are more complicated. Often they require additional libraries.

In short, you'll want to pick a particular kind of input/output you want to try and learn how to do that specific one. Some examples:

  • Web scraping / bots. There are python libraries to make web requests and receive the results. You can write your own application that allows you to make requests of webpages, automatically parse the response, and then make a new request, etc. This can be quite complicated with modern webpages using javascript, but there are also some website-specific APIs you can use to make it easier.
  • Web server. You can use a python library that lets you serve your own web content.
  • GUI application: There are many different GUI toolkits for python. Each one will require a fair bit of learning.
leogodin217

"Never automate what you can't do manually".

I would make a flow chart of all the steps. This gives you the design of your program. Then, start coding each step.

killbeam

In early June, I got a new job but there wouldn't be any work for 2 weeks. Since the job is all about visiting clients at their homes, I figured it would be nice to know how long of a drive it would be to each appointment.

So I started looking into how I could get travel time information. I know Google has very good APIs and quickly figured out the Distance Matrix API was just what I needed. Then I started figuring out how to actually use it (what commands it took, how to call the API from python, etc). This process took a lot of trial and error, reading the API documentation and LOTS of googling.

When that worked, I wanted to create events in my Google calendar so I could clearly see how long I had to drive. To do this, I learned how to use the Google Calendar API.

Then I wanted to make the app available to other collegues, so I googled around and found a tutorial for Flask, to turn my script into a web app.

In short, I started with a general idea which kept growing and growing. Focus on trying to get one part to work, and then go from there.

brnlng

A relatively new GUI library I find worth keeping an eye on or using already is PySimpleGUI.

r-_-mark

This thread is why I love Reddit

OnlySeesLastSentence

Use cxfreeze with the quickstart setting (I think it's cxfreeze-quickstart)

I used to think python sucks because you can't make exes but then I found that (and PySimpleGUI. Shout-out to /u/mikethewatchguy who also is a huge fan of that software :p) and haven't touched my beloved C in forever.

Codes_with_roh

Checkout the smtplib module for doing the stuffs as mentioned above. I build a similar thing as you mentioned. I would suggest you to first try the project on your own and if you can't then I could share the link of my github.

dogs_like_me

I think the real question you are asking is how to deploy an application you built with python. One of the simplest, most flexible, and most popular paradigms right now is to deploy python apps as web services. There are a lot of serverless approaches like AWS lambda that basically just require you to upload your script and define an API to make your thing usable. If you don't mind running stuff off your computer, you just add a timer mechanism to your program to check your email periodically or whatever.

Also, I'd be wary with emails. I think there are some complexities attached to that particular use case you're probably not going to encounter until you try to build it, like getting around spam filters.

pydanny

You might find Practical Python Projects really useful. It's 12 applicable projects in one book, and also teaches you how to extend them into your own thing. While I helped edit the book, that doesn't change the fact that it seems pretty much what you are looking for.

i_ask_stupid_ques

You can try and read the flask mega tutorial ok the internet. It walks you thought the process of building a blogging application with python and flask which is a python framework .

Ondrysak

Divide and conquer my friend :)

hellotheresksksk

RemindMe! 5 days

RemindMeBot

I will be messaging you in 5 days on 2020-08-26 10:06:10 UTC to remind you of this link

3 OTHERS CLICKED THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


Info Custom Your Reminders Feedback
thedjotaku

IN what sense are you looking for help? I'll give you some ideas to pick:

  • I don't know how to structure my project directory and files to that I can make/upload a package to PyPi
  • I am struggling with coming up with a useful project to make?
  • I know what I want, but not how to start?

I'll give an example of my path. While I've been a self-taught programmer since I was about 8 years old, it's only in the past few years that I've made truly useful code. For that useful code I started off with Bash and Python and every time I found myself doing repetitive work that a computer would be good at, I would automate that with either Bash or Python. It made life easier for me and helped me learn how to build useful programs. From there I just started to look around at what would help me in my life.

My useful programs:

  • A program that computes my amortization tabe for how much I owe on my mortgage that adjusts for whatever extra amoutn I was able to pay towards the principal that month
  • A program that uses the Extra Life JSON API to provide an overlay I can use on my videos to show how much people have donated towards the hospital I'm supporting with that charity
  • a program to manage BTRFS snapshots

A few more things that can help you:

  • MagPi and Hackspace magazine both have code projects (a call-back to the good old days when computer magazines had code in them so you could actually have something to run on your computer) and they often use Python
  • Check out the exercises at PythonMorsels
  • Look at the Python Awesome list on Github
azs2005

I dont know if anyone said it or not. I recommend flask. in my opinion, it is the best versatile web framework.

you would be able to view and reply emails based on their contents, on a webpage. store sama data in the db and perform automated tasks with redis queue.

[deleted]

It can be tricky when trying to solve RL problems, without much experience to go on. Take your email example. Your problem definition isn't yet fleshed out. You probably mean you want something that will reply, once, to new email messages. So whatever solution you come up with needs to accept 1 or more new emails, reply, and then remember it has replied, and perhaps catch up if it stops working for a few hours, then gets started again, and new emails have arrived in the meantime. How does it get those emails? Most email servers use IMAP, so a good place to start would be an imap library for python. Do some googling, look for a good library with examples that people have written. Set up a new test email account (don't use your real one yet!) and see if you can get your python app to log in and retrieve a list of emails. How do you know if you've replied yet? Emails can have headers, so perhaps you want to attach a new header to an email once you've replied. Like "X-Replied: Yes". So your app needs to retrieve the headers for all emails (since a certain time.. look up 'high water mark'), look for your replied header, and if not found, send an email, and attach that header, and save the change. When it closes, it probably wants to save the high water mark (current timestamp?) somewhere so next time, it won't have to load 10000 emails. Once you start diving into a problem, the practicalities of how to write it emerge.

[deleted]

Sending an email is a new problem in itself. It obviously needs to go back to the original sender (so long as the original sender has a valid reply to address, which should be used in preference to the from) with a Re: subject and headers that reference the message id of the original mail, so that threaded mail clients will show it correctly. You also want to consider what happens if they have a bot running that auto-replies to all emails, with an email.. many mail servers in the past have been exploded by two bots replying to each other infinitely. So then you have to think about rate limits, perhaps a map of addresses with the number of emails you've sent, and if that ever exceeds a certain number to an address, stop replying.

villa171

Actually I'm creating a web scraper to recollect phone prices quickly. I really enjoy learning while doing a project. Look for something you need, automate something that you do almost everyday.

[deleted]

diffrent libraries, like discord or googleapi

r-_-mark

RemindMe! 2 days

RobinsonDickinson

I wish I didn’t find the answer to this question now all I can think about is debugging.. it follows me into my dreams aswell.

hellotheresksksk

RemindMe! 7 days

RemindMeBot

There is a 1 hour delay fetching comments.

I will be messaging you in 7 days on 2020-09-03 04:02:26 UTC to remind you of this link

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


Info Custom Your Reminders Feedback
thrallsius

solid

first step is to stop using obscure subjective abstractions like this one

build something that solves a problem. your own problem. even a small problem

urgaeifureadmyname

I'm steel noob in python so I cant participate