r/learnpython • • Feb 28 '20

I finally wrote something useful!

Sorry, I really don’t have anyone else to gloat to. I’ve been really trying over the past year to wrap my head around python but thought I would never get it after trying a bunch of boring online courses. I recently got the book “Automate the boring stuff with python” (I’m about half way through) and it made me start thinking about things totally differently. The way the book explained why stuff didn’t work really made things click.

A couple days ago an idea popped into my head for a project that would actually be useful for me. I wanted to take an eBay page url, drop it in and have it generate a pdf to a specific folder. I’m an eBay seller so I figured it would be nice to track some items since eBay only keeps sold records for 90 days.

I wrote it out on paper, worked through some issues and after a day, I have a code that takes an eBay url you enter,has you choose a file name, generates a pdf of the page with the name entered, creates a folder on the desktop and puts the pdf in the folder. Now I’m sure it’s messy or could have been done differently but I learned so much in the process, and it works!!

I never thought I could figure anything like this out but thanks to this sub for motivating me, I’m finally seeing progress!!

439 Upvotes

71 comments sorted by

14

u/emmascorp Feb 28 '20

Congrats! I barely started to learn python! Youve only read one book?

29

u/Ecto-1A Feb 28 '20

Keep at it! The thing that held me back was not having any ideas for something I could write that was practical for my life. Find something you are doing every day and try to find a way to do it quicker with a code. Find a code where you know the final outcome, look through the code and try to figure out what each part is doing and try to figure out what’s going on when that part executes, I found this the most fun way to really get started

1

u/oblivion-age Feb 28 '20

I work at a warehouse now and boxes get scanned on a line, the software goes retarded if you send one out of order so then you have to force them, but there are 2 lines running simultaneously and if one is backed up with a lower box number I run the higher ones through. Then when the lower ones run finally they show as being out of order, which they are but I kind of wish the software was a little more intelligent to realize the fact that I'm forcing the others and that essentially it is all in order at the end. Hard to explain I guess and it isn't something I can fix, but I see the weakness.

2

u/Ecto-1A Feb 28 '20

Really doesn’t seem too difficult to just have the list re-sort to the proper numerical order every few minutes and at least minimize the amount of times thing go out of sync. Or some sort of scan buffer time of like 5 min or whatever before it starts complaining about order. I don’t know, I’m new here to and conceptually this is what makes sense to me.

1

u/oblivion-age Feb 28 '20

Yeah, the problem is one line is coming from QC and they are slower, I get what you're saying. What I was thinking was for the system to say

"oh hey there is #45, where is #42? Oh it got routed to QC and the last one they got was behind on time from the others, so we will reorder once that gets sent through, but for now let's pass the rest on so production can continue."

I think this is how a programmer thinks, maybe not, but would like to think so! I'm new also and I am not sure what type of language this would all be dealing with, I'm sure there is some sort of SQL involved but not sure, it is all networked.

Edit: where I see the problem for me is where I am, at the end of the line when boxes are being palletized, order shouldn't matter because each run is a whole order, like hundreds of boxes.

3

u/emmascorp Feb 28 '20

Ok thanks for the advice!

2

u/Knitcap_ Feb 28 '20

The further into Automate the Boring Stuff you go the fewer practice projects get laid out for you, but also the more project ideas it gives you. Sounds like it's right up your alley.

1

u/workw0rkworkwork Feb 28 '20

I'm honestly surprised so many people here are dependent on books. I guess that may be the difference between the people with no coding experience vs people with some experience in other language(s).

1

u/emmascorp Feb 28 '20

How else do you learn it? I don’t have anything else to learn from.

96

u/zemuse_sound Feb 28 '20

Post it up and get comments on how to improve. Well done!

53

u/taiguy86 Feb 28 '20

Next step maybe take specific fields you are tracking, put it into a database, and run over a ton of urls on a daily basis, and build some analytics to see which items are popping, etc

0

u/[deleted] Feb 28 '20

[deleted]

10

u/SenKaiten Feb 28 '20

what if i do though? ☜☜

0

u/[deleted] Feb 28 '20

[deleted]

3

u/namvu1990 Feb 28 '20

You certain will make paypal ebay and shipping companies happy. Not quite sure about your own wealth though.

2

u/[deleted] Feb 28 '20

This is the definition of the modern stock market though. It's what caused the crash in 2008.

Bots programmed with algorithms that detect the slightest changes in trading volume and try to predict what is going to happen, then buying or selling based on that.

4

u/take_it_easy_buddy Feb 28 '20

COVID-19 intensifies

3

u/[deleted] Feb 28 '20

let's hold hands while we skip over to wallstreetbets

3

u/hamsumwich Feb 28 '20

While trading bots are an issue that can cause sudden market dips, they were not the cause for the '08 housing market crash. The cause was an unregulated derivative mortgage loans that were sliced and diced and repackaged together. Absolutely risky loans were packaged with solid loans. People were approved for for $500k loans, even though their income was seasonal fruit and vegetables pickers. Adult entertainment strippers held several mortgages for more than one home. It was criminal what the banking industry did, and yet no one went to jail for it. A great book to better understand the crash is The Big Short by Michael Lewis. The movie based on the book is good, but unsurprisingly not as deep as the source material.

1

u/ChemiluminescentGum Feb 28 '20

That’s not what happened in 2008. T may have been a minor contributing factor, but far from the cause.

1

u/[deleted] Feb 28 '20

I understand it's a super simplification of the problem and the meltdown that occurred, but it was a big cause of the selloffs that happened and many other "blips" in the market, algorithms gone haywire trying to game the system. In the end was bad choices made by humans.

2

u/ChemiluminescentGum Feb 29 '20

It would have been more accurate to say the 1987 crash was caused by auto trading because that occurred when the market went down and tripped massive stop-loss orders and then the problem cascaded across the market.

4

u/Kriss3d Feb 28 '20

There was a guy who made one for stocks with an api that could do 5 actions per minute. He then monitored 5 stocks and had it buy and sell by if it's over the average.

I'm 5 days he made 23$ on a 5000$ base. Though it didn't spend them all. But only 1/5gh or so I belive.

So. Not bad.

3

u/[deleted] Feb 28 '20

Is this the guy? For reference: he gave the bot $1000 and it made $23 in 3 days - the rest of the week it didn’t make or lose anything. He could only pick 5 stocks as he was using a trial account

2

u/Kriss3d Feb 28 '20

Yup.

2

u/[deleted] Feb 28 '20

His stuff is really cool, I like his insta bot

1

u/CaptainFoyle Feb 28 '20

And who's gonna pack and ship all that shit? You'd probably be packing parcels all day...

7

u/fssyed Feb 28 '20

Congratulations!! I know the feeling. This is just the start my friend!! Keep at it

4

u/thedjotaku djotaku Feb 28 '20

Congrats! That's the biggest stumbling block with coding. You learn from some book and, if you're lucky, they have some toy programs that show you how to put that code to use. But they're just toy programs. And you don't want to make the hundredth text program or web browser or Tetris clone. So you languish. What do you do with this newfound knowledge?

Then, one day, you have a problem that you realize can be solved by programming. Maybe it's automating something you find tedious. May it's evaluating some data in a way that's hard for humans and easy for computers. BOOM! Now you are inspired!

Next step is creating some stuff you share to github, PyPi, etc and start getting users. THEN you REALLY feel like you've made it. The first time I got a bug report on one of my programs was a super happy day for me, because I knew people were using my software!

3

u/Robbzter Feb 28 '20

Cool idea, keep it up! Creating your first solutions to real world problems is truly an amazing feeling.

3

u/asynchronousdelta Feb 28 '20

Well! I've also made a lot of progress by creating my Discord bot.

It's cool to see that we all kind of work the same way – we need practical training!

3

u/[deleted] Feb 28 '20

Dude yeah making a Discord bot got me fired up about programming after not really caring about it for a while. It's simple, but you can make it do anything. I made mine pull data from Reddit using PRAW

2

u/asynchronousdelta Feb 28 '20

PRAW?

Also mine is a multi utility bot so I learnt how to use asyncio, Web requests and python in a more general way all in one 😊

2

u/[deleted] Feb 28 '20

Python Reddit API Wrapper

1

u/[deleted] Feb 28 '20

That sounds like n awesome combo! :)

1

u/asynchronousdelta Feb 28 '20

Yeah, I had to look at all kind of different libraries to fulfil my objectives with the bot :)

So you've made an advanced webhook for reddit on Discord?

2

u/steno5 Feb 28 '20

Congrats! I am also learning using that book. Have finished Part I and continuing. Hope to share same story like this soon.

1

u/Knitcap_ Feb 28 '20

What are you learning now that you've finished the book? I'll be in your shoes soon and am unsure of what to do after.

1

u/steno5 Feb 29 '20

No, I have only finished the basics part of the book (Part I). Now I am practising what I have learnt with some workbooks out there, like:

- https://www.amazon.com/Python-Example-Learning-Program-Challenges/dp/1108716830
- https://www.amazon.com/Python-Workbook-Introduction-Exercises-Solutions/dp/3030188728/ref=sr_1_1?crid=TBKQWM2L1QF1&keywords=the+python+workbook&qid=1582937410&s=books&sprefix=the+python+w%2Cstripbooks-intl-ship%2C352&sr=1-1

I find both these two workbooks useful. After that I will continue with Part II and the rest of the "Automate the boring stuff with Python"

1

u/Knitcap_ Feb 29 '20

Ah, I see. Personally I try to go by the book as much as possible and build programs for work as I go. I currently have a bottom of the corporate chain job that consists mostly of repetitive tasks and I've already automated a handful of them. One of which was a program that moved ~12000 files out from one folder and into another that took me an hour to make, buy probably saves several days worth of doing a mind numbing task. That was one of the easier ones I made, but the one that impressed my boss the most.

I'm trying to get to a working proficiency with python asap so I'm trying to go through the learning process as fast as I can before the bills catch up to me.

1

u/steno5 Mar 06 '20

I see... I once used Excel VBA to automate the process of creating and printing the bank remittance orders and felt quite good about it. Now I'm trying to learn python to extract data from companies 's financial statements for our data analysis. In my country, all companies submit pdf files with scanned images in them, making us data analysts a bit hard to process the data.

2

u/Knitcap_ Mar 06 '20

I know the feeling, I often deal with scanned images of certificates that need to be read manually for expiration dates. I suggest you try pytesseract to read pictures. In my experience it works flawlessly as long as the image quality is decent. Saved me a substantial amount of work so far.

1

u/steno5 Mar 07 '20

Oh, thanks. I have been trying with pdftabextract but not yet successful. Thanks for your suggestion.

2

u/naj690 Feb 28 '20

Good for you! I'm slowly catching up. The book is really amazing, among the few that's actually practical.

2

u/mrjohndoe95 Feb 28 '20

I also like web scraping a lot. But haven't done anything substantial yet. Your project inspired me, I will also build something that interests me. Thanks for sharing, and share your code as well. Keep hunting

2

u/muicontento Feb 28 '20

This post really motivates me. I think a lot of people are in the situation of learning the theory but not feeling the joy of producing something meaningful. Congratz u/Ecto-1A

2

u/mholloway808 Feb 28 '20

When I started out I used the book 'Python Crash Course' by Eric Matthes religiously -- it's the ideal starter book, imho, you might still find it useful if you don't have it yet.

Then when I was ready for intermediate / advanced stuff, the best book I found was Powerful Python by Aaron Maxwell.

Both of these have been invaluable to me, and I come back to them again and again for follow-up, review, reference. I'm similar to you in that I've spent a year with Python as someone with no prior coding background. Good luck with your continued endeavors!

1

u/VeLoct84 Feb 28 '20

Congrats! Keep it up!

1

u/the_battousai89 lifelong beginner Feb 28 '20

Congrats! Very inspiring!

1

u/Deva161 Feb 28 '20

Great job man! Keep up your good work.

1

u/siktha Feb 28 '20

Congratulations!! Never stop..

1

u/jusgarciape Feb 28 '20

Congrats man!
Now it's you who motivates

1

u/BomB34R Feb 28 '20

would you like to upload your code to a public repository? You have a really interesting idea and I would like to see how you're progressing! :)

1

u/11pascal Feb 28 '20

Keep going forward. That sounds very good.

1

u/poeblu Feb 28 '20

The great thing is the more you learn, for instance scan the directory and parse IMO an array for a GUI. This is the best part, in a year from now that could be a robust program that you keep adding features.

1

u/tashibum Feb 28 '20

scan the directory and parse IMO an array for a GUI.

What's that do in English?

2

u/poeblu Feb 29 '20

It allows you to parse to a data frame (pandas) then organize them by topic for a interface that would allow for quick knowledge

2

u/tashibum Mar 02 '20

Ah! Thank you! I'm still learning the basics :)

1

u/oblivion-age Feb 28 '20

Good job! You sound like me right now, idk what the hell to do, but I'm working on web stuff atm, was in python and got a little bewildered as to how I could use it now. If that book helped you maybe itll help me, it is also free online. I've seen it recommended a lot and have skimmed it a bit. Thanks!

1

u/Poddster Feb 28 '20

Now I’m sure it’s messy or could have been done differently

If you're interesting in feedback in this regard you can post on https://codereview.stackexchange.com/

1

u/williamt31 Feb 28 '20

Congrats, on making a working program.

My only suggestion would be to create a free github account where you can share your code easily and sync between machines. Personally I have 1 private repo for stuff on my home network and public ones for stuff I want to share with friends and the world that way you can easily link it and people can comment if you're interested in that.

0

u/[deleted] Feb 28 '20

[deleted]

1

u/Ecto-1A Feb 28 '20

I’m using pdfkit for the conversion from HTML to pdf

1

u/Knitcap_ Feb 28 '20

Probably the combination of bs4 and requests or just selenium for the webscraping and pathlib for creating the folder on his desktop.

3

u/[deleted] Feb 28 '20

[removed] — view removed comment

2

u/Ecto-1A Feb 28 '20

I was just checking out beautifulsoup, I think my next project will be using that to scrape the actual data from the eBay pages and dump it into a database

1

u/[deleted] Feb 28 '20

[removed] — view removed comment

3

u/Ecto-1A Feb 28 '20

Writing it down helps me visualize all the parts needed to solve the problem, just a list of tasks that the code will need to complete. for example. Name folder-create folder-ask for user input of url- write input to ebay_url etc.

6

u/Deva161 Feb 28 '20

Because planning is so important.

1

u/[deleted] Feb 28 '20

[removed] — view removed comment

2

u/Deva161 Feb 28 '20

I guess writing code on paper is also a good thing and essential skill.

4

u/Taran29 Feb 28 '20

I don’t think so. Writing down your logic and the flow of your project is important, but not the actual code. It’s like when you prepare a speech, you write the important talking points and not the whole speech word for word