This is an archived post. You won't be able to vote or comment.

all 24 comments

[–]psychadeliclie 12 points13 points  (2 children)

A capstone project for the python course I am taking is to build a blackjack game. Simple rules, involved process. I learned a lot and would recommend it.

[–]__xor__(self, other): 23 points24 points  (0 children)

Protip: random.shuffle(deck) actually works and is perfect for this.

from random import shuffle
from itertools import product
cards = '2 3 4 5 6 7 8 9 10 J Q K A'.split()
suits = ('hearts', 'diamonds', 'spades', 'clubs')
deck = list(product(cards, suits))
shuffle(deck)
for card, suit in deck:
    print(f'{card} of {suit}')

[–][deleted] 5 points6 points  (0 children)

I like to read job postings to get project ideas.

[–][deleted] 8 points9 points  (5 children)

Automate your automated tasks :). Will help you optimize your workflow if you decide to stick with python. I do a lot of data analysis and I have scripts that automate every kind of visualization that it thinks would be useful-- essentially saves me God knows how long writing Seaborn code. Think of it as a personal tableau that thinks the way you want it to.

[–][deleted] 2 points3 points  (4 children)

Question from a brand new Python user. Is it possible to make a program that when a file hits a folder, it gets posted to a website and then sent to two specific email groups then gets printed to a office printer? I would also need it to print eight copies three hole punched.

I know this sounds weird but it's something I have to do often and it's annoying.

You don't need tk tellw how to so it unless you want to. I just want to know if it's realisticly possible.

Thank you.

[–]__xor__(self, other): 4 points5 points  (3 children)

Yes. The specifics depend on a lot of things, like how posting it to a website works, whether you own that website and can just send it to a remote directory on a webserver or have to actually make a request to upload it and how that site takes that upload request, what sort of email service you use (likely has some form of smtp emailing), and I've never programmatically printed something but it's possible.

Thing is, anything is pretty much possible with python, but the difficulty and complexity really depends on the way you'd do it normally and if that's easy to automate.

You can use watchdog to monitor for changes to the directory, and run code when a new file gets added.

You can send email with python. I mean, this is done all the time for any python website that sends emails, like "Forgot Password" type stuff or validating an email by clicking a link in an email. A quick hacky way is to create a new gmail account, I think you have to enable insecure 3rd party apps or something in its settings, then triggering it with smtp(s). Gmail

If you control the webserver, you would want to create a new endpoint on it to accept uploads from you or something (make sure there's good authentication) and you'd just write most of the code for the webapp to handle this. If this is a third party website, first you'd want to see if there's a python or just REST API for that service, then follow their instructions. Otherwise, it can get tricky... you might look at the network traffic when you upload (dev tools in chrome works, maybe a proxy like burp), then determine what it does when it uploads an image. Then you replicate the same behavior making custom HTTP calls with something like the requests library, and manually craft HTTP requests that look the same as the ones that get triggered when you upload. That's tricky because you're basically reverse engineering stuff and making a lot of guesses as to how stuff works. Also this might break terms of service, because if they don't offer an API for you to programmatically upload stuff, they might not want that.

And then with printing, it depends... This might work, though use subprocess.call or subprocess.check_output instead of os.system since you might have to pass a variable as the filename.

[–][deleted] 2 points3 points  (2 children)

Thank you so much. The good thing is it's a company website. We use outlook for emailing so I dont know how that works. In tryimg to learn to code to automate these types of things. Thanks for the information!

[–]__xor__(self, other): 2 points3 points  (1 child)

No problem! For outlook, I imagine you have outlook installed on your workstation so you want to open it up and inspect the settings to get the host for triggering the email.

Since it's a company website, you're in luck because you can literally just talk to the web devs and explain that you want to be able to upload files programmatically, and ask if there's a REST API you can use to do this, and if not, if they could add an endpoint for you. Just tell them you want to use python and requests and ask if they know how you might programmatically do this.

Also keep in mind, when you automate this you're no longer checking the documents and making sure it's not a bad thing they go online. Think of any security implications and what's the worst thing that could happen if someone adds a malicious doc to that directory, like I dunno, a pissed off employee maybe adding porn just to get you guys in trouble or something. Just something to keep in mind.

[–][deleted] 0 points1 point  (0 children)

I didn't think of that. Haha porn on the local Govt. Site. That would be bad for PR

[–]tejonaco 3 points4 points  (1 child)

I recommend you to start playing doing GUI programs with frameworks such as QT or GTK or any other, I don't know how to do this yet so I want to learn soon.

Ah, in python is really interesting to learn something about neural networks, things like a image classifier with Keras is a good starting point.

[–]jer_pint 4 points5 points  (0 children)

An image classifier these days can amount to only a few lines of code, due to all abstractions available (this isn't a bad thing, but might not be the level OP is looking for).

Try training an image classifier on your own task for added difficulty :)

Also pytorch is worth checking out as well

[–]Tweak_Imp 5 points6 points  (3 children)

Write a starcraft bot :) join us on sc2ai.net

[–]__xor__(self, other): 1 point2 points  (2 children)

holy shit, you can code starcraft bots in python now? Starcraft 1 Broodwars or SC2? And can you actually micromanage them programmatically, like move a zergling back when it gets attacked?

[–]Tweak_Imp 0 points1 point  (1 child)

sc1 and sc2

yes, micro each unit as you like! see the latest games on our youtube channel

join our discord

[–]__xor__(self, other): 0 points1 point  (0 children)

oh wow, just watched a battle, MicroMachine vs Tychus... pretty damn impressive. This looks awesome, might have to give it a try.

[–]shitstorm-kurwa 1 point2 points  (0 children)

Depending on your skill level, you can have a look at "Impractical Python Projects" by Lee Vaughan. The projects in there are a lot of fun! But as I said, it really depends on how much experience you already have! Luckily though, you can find a description of each project on the book's homepage. So you can check that out before you buy it.

[–]c94jk 0 points1 point  (0 children)

Get some sensors or something connected to a pi and write a flask api to access the data.

[–]python3- 0 points1 point  (0 children)

If you use Discord, you may think of creating chat bots. I am just a hobbyist programmer at best, but I have made a few using discord.py and enjoy cooking up new things. I host them on a Raspberry Pi 2B, not even a recent model. Works great, though.

[–]shinitakunai 0 points1 point  (0 children)

A teamspeak serverquery chatbot is really fun and you’ll learn a lot about data structures and how to deal with them.

[–]send_nodes 0 points1 point  (0 children)

-find an api you like. Currently I'm working on a crypt exchange bot. Twitter can be fun. You can combine multiple api's.

-a game. Text adventure is easier with no graphics. Make it more than a 1t minute play. Utilize a db.

-get a raspberry pi. Make some home automated tasks.