What are you working on Sup Forums?

What are you working on Sup Forums?

I wrote a program that will automatically email my girlfriend once each day while I'm gone innawoods

#! /usr/bin/env python3.

import smtplib
import schedule
import time

def emailThis():
mail = smtplib.SMTP('smtp.gmail.com', 587) #Creates SMTP object
type(mail) #Makes sure 'mail' is an SMTP object

mail.ehlo() #Helps establish connection to the server

mail.starttls() #Enables encryption for connection

mail.login('top', 'kek') #Logs into mail
#235 as return value
#indicates successful
#connection
mail.sendmail('top', 'zozzle',
'Subject: Daily Reminder. \nI love you a ton!')

mail.quit() #Closes connection

schedule.every().day.at('00:35').do(emailThis)

while True:
schedule.run_pending()
time.sleep(60)

#run program with:
#nohup python3 autoEmail.py &
#kill program with
#kill *PID number given after running*

Fag.

>Fag
>Has a girlfriend

At least it's not a waifu.

>I wrote a program that will automatically email my girlfriend once each day while I'm gone innawoods

that seems pretty obnoxious or she sounds pretty needy. take your pick

Or it's cute and funny, depends on the relationship
>inb4 samefag

there's no spontaneity in the email. it's the same dumb subject and message every day at 12:35am when you're in the woods. that kind of gesture gets extremely tedious after 2 or 3 iterations. if she hasn't filtered it after a week's worth of that email in her inbox, there's something wrong with her.

at least put in a set of cute shit to say like references to good things in your relationship (like your first date or her favorite food or whatever. literally, anything that demonstrates you think about her) and randomly pick one of them to put in the message. or *something*.

this is a bizarre mix of effort/explicitness and utter laziness. like you're *drawing her attention* to the fact that you're half-assing it. if you're going to be out of contact, just be out of contact. if you're going to feel guilty about it, make it up to her when you get back. but don't do these impersonal half-measures.

and none of this is even talking about the shittiness of your code. `type(mail)` doesn't ensure that mail is an SMTP object. it just returns the type. to ensure that the type is correct, you need to *compare* it against something. preferably compare to make sure it's an SMTP object, if that's what you want (which from your comment seems to be the case). see lines 3 and 4.

and for fuck's sake don't EVER put login credentials in your code. put them in an environment variable or in a settings file or something. see lines 5-9

>type(mail) #Makes sure 'mail' is an SMTP object

Normally mistakes and misconceptions can be excused, but because you're so cocky and smug about your babby's first programming, you should kill yourself you utter retard.

wow ur such a hacker pls don't hack us :D

Kill yourself too, because of your cringe-worthy, bragging in your screenshot.

this guy gets it

what the hell is bragging in my post? it's just an illustration of what i'm talking about. are you one of those dumb niggers that thinks a magic trick is actual magic?

With your cringeworthy printing of environment variables and reading JSON formatted data, idiot. The fact that you think that was cool or impressive enough to include shows how smug you are about your babby's first programming related topics.
Kill yourself.

Holy fuck Python is so fucking garbage, I get sick looking at this dumb shit.

Why didn't you just use PHP for this shit, it would been like three lines.

fuck you cia niggers

GNUmale Lincuck is just mad he can't afford a Mac, ignore him.

This is the best post I've read in 2017

Seems you're new to this, OP. I'll take it as you're trying to crowd source advice, rather than showing off your... code. Best way to get someone to help you with something on the internet is by being wrong, after all.

(1) Scheduling
I don't consider your script running on a while True loop good practice. You can easily schedule this script to run once per day with something like crontab. Most linux distros (which I assume you are using since you include a shebang in the first line) will have some variation of this.

(2) Unlike user at I see what you mean when you use type(mail). I assume you are trying to include a sort of log with nohup's autogenerated nohup.out log file. Frankly, you'd want at least a print(type(mail)) in there before it shows up in nohup.out. Best practice is to use the logging module. Even better is to catch a type error with try/catch; and log it with logging.

Note that logging module has quite a lot of depth, but at the same time you can use it casually; i.e. beginner friendly but fully-featured if you know how to use it.

(3) As user at id above has pointed out, vary your messages. Do some madlibs shit. You can save message templates in one file (one per line), and pick one at random with randomint(). You can save words in another, and blah blah so on.

Read up on using file I/O (i.e. file.open(), etc.)

To add on to my previous post, this dude seems to think you're bad because you lack effort or something. I think you're bad because you're bad. You're clearly new to coding (or python, at least), and this is the best you could have come up with.

Keep it up, though. Everyone starts out like this.

The fuck is with your commenting!

Got a question here

How do i open a file that's already running in the taskbar with python. As in, i've tabbed out from a video game and i'd like to open it automatically.

aight thanks.

you wrote a program that gave me cancer

whaaaaaaat?
you mean like alt tab or open a text file?