r/learnpython • • Feb 29 '20

Actually used python today

I've been learning python for about a month now. I started with automate the boring stuff like so many others have. Since then I have made some small games to practice. I am currently working on a hangman game and needed a list of words to use. I found a list of words and copied the whole thing to a .text file but it came with extra stuff I didn't need. So instead of manually deleting everything I didn't need I made a python script to do it for me. GREATEST FEELING EVER.

393 Upvotes

63 comments sorted by

63

u/schwitaner Feb 29 '20

What boring stuff did/can you automate?

3

u/dstnmyrs Mar 01 '20

I deleted numbers and whitespace from a text file to leave just the words. Would have taken a lot longer if I did it manually. Three minutes to write it and 1 second to perform it.

14

u/Nixellion Feb 29 '20

a lot of boring jobs can be completely automated :D

8

u/[deleted] Feb 29 '20

Like what? I work as a Help desk and want to learn Python, but I can’t think of what it would be useful for.. :(

30

u/Nixellion Feb 29 '20

Well, try contacting microsoft support and you'll realise that its a bot, most likely written in python :D

The logic is - what repetitive tasks you do? Do you have to do the same thing more than 3 times in short period of time? Then its likely it can be automated, the question is how.

4

u/[deleted] Feb 29 '20

Off the top of my head I can’t think of anything to be honest and most issues I can fix pretty quick or it’s a printer issue lol

4

u/Nixellion Feb 29 '20

Well I dont know how helpdesk works, you'd have to describe your daily routine for me to be able to think of something

6

u/[deleted] Feb 29 '20

It’s pretty boring. I get in to work and go through all my tickets to see the new ones that get auto assigned to me then determine next steps and schedule them. I then watch YouTube or Anime and do the tickets.

I don’t know how people find stuff to do with Python! But maybe my job just sucks lol

8

u/Nixellion Feb 29 '20

Mhm, well, that's very general overview of what you do, you need to go deeper into details. What actions do you perform? How do you find tickets? Where do you look for answers and info for them?

Though from this general description it looks like it's just already automated for you. You most likely get tickets from some application or system, which most likely runs on a central server and is likely, surprise, written in Python :D Or something similar.

So yeah, some jobs are already automated for you and it's hard to find something. But you can automate stuff outside of your job too. Or find another job :D One that can get help from python. I work with gamedev and VFX and there's ton of stuff that can be automated, and it's so happens that Python is industry standard scripting language for CG software (except Adobe because they are huge shlongs)

8

u/sportsroc15 Feb 29 '20

Yeah people don’t understand that most of the already automated stuff we use are computer scripts and what we do as software engineers is work with that already automated software and update it and make it better as time goes along. Also automate new things as needed.

5

u/Yakhov Feb 29 '20

Write a script that reads each ticket, uses key words to generate an auto reply to the problem and closes the ticket.

3

u/[deleted] Feb 29 '20

I'm curious about this, mainly for the scanning. We can't close out tickets right away, as we're expected to reach out to the user (yay customer service /s).

Would I need special access if our ticket system is web based, or would it be better to just scan the ticket notifications we receive in email instead as it has the pertinent issue in that email (no user details).

3

u/Kryma Feb 29 '20

You could use selenium to interact with the web-based system!

→ More replies (0)

2

u/Yakhov Mar 01 '20

You could scrape the web stuff with beautiful soup, or thers proly an easier way to get it from the email. I seen tutorials on sentiment analysis for tweets or whatever. You proly already have a bunch of boiler plate responses to trigger based on the content keywords; run it through a neural network to select the best response and fire off a reply. THen go watch more tiktok

2

u/[deleted] Feb 29 '20

You can get in to proactive incident management. I have a lot of experience with this. I use my scripts to scan for and remediate problems before the user sees them.

After a couple of years of proactive incident management, we brought incident reports down from ~160,000 tickets a year to ~70,000. Were still continually improving this program.

Do note, I am an engineer, not front line support. If you go this route, make sure your management backs you and is willing to elevate your position if you make things run smoother. Otherwise you may make yourself redundant.

1

u/[deleted] Mar 01 '20

Could you give me an example by chance? This sounds quite interesting.

1

u/[deleted] Mar 01 '20

We went after the biggest fish first. For example we poll printers and print server queues looking for issues. If the printer isn’t responding to print jobs, we issue a reboot to it. If that doesn’t clear, we kick a ticket off to desktop and have them stop by. If the printers hostname starts with KM, we issue a service request to Konica Minolta since it’s an MFD under contract. We purge print queues and restart print services nightly to keep things tidy. We have somewhere around 16,000 printers, so things can get hairy.

We ingest logs and SNMP from every computer, server, and network appliance. We look for common issues like packet loss, failed windows updates, TPM chip issues, bitlocker problems, BSOD, brute force attempts, account lockouts, VPN instability, POE failure, access point outages, saturated links, etc etc.

We have also created a self service portal that eats up a lot of the password reset calls. If a user is locked out, they can use their neighbors computer to navigate to the portal and reset. Users can put in other tickets here too. This also reduces call volume and frees up level 1’s to troubleshoot and triage as necessary.

We’ve automated as many things as we could before issuing a ticket to a human. A lot of the inbound calls are just human error or help with an excel formula now.

2

u/[deleted] Mar 01 '20

I am pretty sure you could write a script in python that will watch YouTube for you!

1

u/MotionlessMatt Feb 29 '20

Have python get the new tickets for you. It can surely be done!

3

u/barryhakker Feb 29 '20

Part of the learning process is going though existing functions and realizing how you could put a few of them together to do some basic task for you. Even when you do a basic python challenge it’s amazing to see how different people came to the same results with different methods.

3

u/[deleted] Feb 29 '20

If you have any regular reporting to do, I have found Python to be a very helpful helper. I use Pandas and Matplotlib to automate a reoccurring report that was quite the waste of time.

Every third week or so I get an Excel spreadsheet of vacation and sick leave balances for approximately 1500 employees from a legacy system. The report gives the first and last name, their salary (but not the hourly wage), the leave balances, and the employee's position number. The position number contains the employee's position job number, and the division and branch they work in (e.g., 123-321-4444), all of which is needed for the final report.

The script I wrote: extracts the position, division, and branch identification, calculates the hourly salary, and aggregates the leave balances according to unit, branch, and division for each level of employee. These aggregations are used to create heat maps for each organizational level with the balances (because management loves heat maps, sizzle sizzle), and then a cheeky little printout using f-strings that describes the heat map or individual employee. For example, there is a heat map of leave balances for all clerical staff in Unit A, all technicians in Unit A, and all Managers in Unit A. Each of these are then rolled up into a heat map for all clerical/technicians/managers in Branch A (which is comprised of Units A, B, C, D, and E), and then rolled up once more for a total of seven-ish Division heat maps. For posterity I use Pandas to create Excel spreadsheets of the individual DataFrames.

To manually accomplish this in Excel, people were spending between 8 and 12 hours across a few days. Via Python, this is completed in under a minute. It takes me longer to email the results to people than it does to do the work.

1

u/Kryma Feb 29 '20

Why haven't you yet automated the emailing too?

1

u/[deleted] Feb 29 '20

The IT shop is afraid of their own shadows and wouldn't let me automate that part of it. Silly, I know, but even getting Python installed was a feat unto itself.

1

u/majik00027 Mar 01 '20

you can automate excel

3

u/8rnlsunshine Feb 29 '20

Can you automate living?

3

u/Nixellion Feb 29 '20

sigh

But actually yeah, sort of, I mean just strictly Python speaking - HomeAssistant is #1 home automation platform right now, and it can automate a lot of your daily tasks. You can then dig into robot stuff, Raspberry Pis, ESP modules, Arduino and automate basically everything, so you'd only need to sit on the couch and everything else will be automated :D Like a bot can order food, robot can drive to the door, smart lock will open it, smart doorbell will tell courier to open the door himself (or you can automate door openning with motors, why not), robot will take that pizza box and drive to you. I mean... While it would sound like sci fi even 10 years ago - it's all really doable now.

Python is also leading language when it comes to neural networks, so yah

1

u/FoxClass Feb 29 '20

Butter passing. Effortless waffles.

-10

u/AcrobaticCricket6 Feb 29 '20

If you like deleting tiny bits of text out of huge files, I have some entertaining stuff for you to do manually. #sorrynotsorry #snark #internetpolice #unnecessary #hashtag #climatechange

0

u/[deleted] Feb 29 '20

[deleted]

4

u/[deleted] Feb 29 '20

AS400 represent!

0

u/[deleted] Mar 01 '20

[deleted]

1

u/Doormatty I get paid to write Python! Mar 01 '20

Most dot matrix printers don't NEED drivers.

7

u/floridaturtles Feb 29 '20

Could you please share the code? I’m a very very beginner and I have no idea how you could code that

2

u/dstnmyrs Mar 01 '20

https://pastebin.com/bGMM9jAH

Probably not the most efficient way of doing it but it worked and it took me only 3 minutes to write. This is the script for 5 letter words BTW.

-11

u/mircatmanner Feb 29 '20

Look into regular expressions in python

7

u/rrjamal Feb 29 '20

Just a heads up: regular expressions are a bitch, and just pointless to tell someone to 'look into' when they barely know how to code.

Besides, OP probably just had to get rid of the '/n' or '/b' or something simple at the beginning/end of each line. Just hard coding that removal would more than suffice.

1

u/ScoopJr Feb 29 '20

Regex101 is a good resource. I usually test my strings in here before grabbing the pattern

2

u/midairmatthew Feb 29 '20

Neat! Next step for hangman: find an API that can serve random words and dig into the Python Requests module. :)

2

u/dstnmyrs Mar 01 '20

I just started toying around with wordsAPI after reading your comment. I'm getting random words and after a few missed guesses it shows synonyms and with 1 guess left it shows the definition. I'll eventually add those features based on difficulty selected.

2

u/midairmatthew Mar 01 '20

That's awesome! Nice work.

31

u/codezoned Feb 29 '20

Great work mate. I'm a software engineer in Tokyo straight Outta uni and the one thing that helped me get my job was to make all my fun scripts into functional opensource projects on GitHub. Try to apply this into whatever you build :)

3

u/[deleted] Feb 29 '20

What’s your github I’m curious what kind of scrips you made :)

2

u/[deleted] Feb 29 '20

Are there jobs in Tokyo (or is there a job market) for Americans that don’t speak Japanese?

2

u/[deleted] Feb 29 '20

As an American who has spent a decent amount of time in various Asian countries (although it's been close to 10 years) I would try visiting before you think of moving there. Lots of people end up being really surprised at the culture, especially in Japan. It's not at all like it's portrayed in pretty much any western media.

I know lots of people who think they'd love Japan because they love anime and games by Japanese studios and all that Jazz and honestly a lot of that is exported specifically for American consumption.

Additionally Japanese is not an easy language for a native English speaker to learn. You can look it up but depending on what your first language is the hard pallet in your mouth hardens differently, making some sounds more difficult or easier to make. Same goes with muscles in your lips and tongue they strengthen depending on what language you speak.

Basically do your research before you try and move to a foreign country. Additionally Japan when I was there was not a high tech culture. Most people's Banks ATMs were only available during business hours and you paid your bills at the local convenience store instead of online. I'm sure some of that has changed in 10 years but it surprised the hell out of me.

5

u/[deleted] Feb 29 '20

Thanks but that didn’t answer my question at all.

We’ve been to Tokyo 6 times for up to a month for travel. We love it there. I only meant, as I asked, is there a job market for Americans who doesn’t speak Japanese

1

u/sinosplice Mar 01 '20

From what I understand, you need to speak/read/write Japanese. Your English is not a huge pro, but your lack of Japanese is a huge con.

1

u/codezoned Mar 01 '20

I work in a startup and don't speak a speck of Nihongo, But I'm good at what I do. Companies like Rakuten, Google and a lot of others don't require you to speak Japanese but they do need a good level in English.

If you want to work in Japan, It's absolutely possible and in some cases easier than the West as there is a need for good software engineers over here right now. I would say APPLY, APPLY, APPLY and ignore everything else.

1

u/sinosplice Mar 01 '20

Good point... non-Japanese companies have a need.

20

u/[deleted] Feb 29 '20

Congratulations buddy!

Fee free to post the link to your code here for getting reviews and suggestions from fellow redditors.

13

u/[deleted] Feb 29 '20

So it begins...

7

u/batch_is_fun Feb 29 '20

Congrats! Learning to automate processes is a great skill! I’m not a software engineer but I work for a growing security company and right now my whole job is to automate processes for the analysts. Things like running through long lists of addresses and checking them with multiple online sources. Tasks that would take hours normally are able to be done in seconds with python. There’s obviously so much more outside of just that, but I figured I’d give my own real world example. It’s really great stuff! Keep it up!

1

u/ErnieCruz Feb 29 '20

Do you mind sharing the kinds of things you check for addresses? Just curious because I want to help automate the checking of addresses for local taxes at my job.

3

u/[deleted] Feb 29 '20

Congrats. Keep it up. After 25 years, Python is still enjoyable to work with.

3

u/[deleted] Feb 29 '20

Your IDE's regex capabilities would probably do the same job way faster than writing the actual regex in Python, but I get it; used to do the same thing, and the joy you get when hours become miliseconds is to die for.

0

u/[deleted] Feb 29 '20

[deleted]

2

u/[deleted] Feb 29 '20

This was a good read, actually. I'll take your sound deductions with me, thanks :)

3

u/thefsfempire Feb 29 '20

I've been learning for about the same duration and I've had a few of these moments myself. Its very rewarding and a lot more accessible than when I tried jumping into C# years ago (don't remember anything of that though lol)

3

u/Stabilo_0 Feb 29 '20

Well done!

2

u/BungalowsAreScams Feb 29 '20

Keep going bud

2

u/krakelen Feb 29 '20

Great work! Share the code, please?

1

u/rommon010110 Feb 29 '20

That is awesome, I am having a tough time getting through the book, hoping Kirk Byers free course sparks motivation.

1

u/vinjuang Mar 01 '20

Ah, nothing like writing a python script for a python script :D good job dude

1

u/Assumptio Mar 01 '20

I remember my first useful python script. My tv was having troubles displaying " " in subs, so i made a script to get rid of them on my subs files. Feels great! Congrats!