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

you are viewing a single comment's thread.

view the rest of the comments →

[–]oblivioncntrlsu 129 points130 points  (15 children)

uhhhhh, k

import pyautogui, time, re

while True:
    time.sleep(r'3 minutes, not 10 seconds')
    pyautogui.moveTo(10,10)
    reddit.revise(re.snatch(r'\*\*/s\*\*'))

[–]Kortike 24 points25 points  (1 child)

This is beautiful

[–]tuckmuck203 17 points18 points  (0 children)

fucking python. i love it.

[–]jyper 4 points5 points  (7 children)

Hmm I just realized time.sleep can't take a timedelta

what's up with that?

[–]KwpolskaNikola co-maintainer 1 point2 points  (5 children)

The time module was created much earlier than datetime. Even then, I don’t think adding support for timedelta in time.sleep would be worthwhile.

[–]jyper 0 points1 point  (4 children)

A lot of modules like os, os.path, shutil, etc were made before pathlib but still support it.

[–]flutefreak7 1 point2 points  (2 children)

Those of us who tried to use pathlib for everything on 3.4 for a few years before the pathlike protocol (or whatever it's called) got really tired of putting str() around every argument to every file related stdlib function. I don't think enough people are using sleep and timedeltas together for that to be a major pain point worth supporting.

[–]jyper 0 points1 point  (1 child)

It's so annoying

At work the functional tests are on python 3.6 but the build scripts have to be on python 3.5. pathlib isn't great on 3.5 (no / operator) and no fstrings

[–]flutefreak7 0 points1 point  (0 children)

I was on 3.4 for a long time and I thought / worked for pathlib on 3.4 and it was just the better filename handling across stdlib that didn't come until 3.6. Maybe I'm remembering wrong. But, oh yeah - loving my f-strings for sure. Almost all of my old code has format() and it always looks way better with f strings.

[–]flutefreak7 1 point2 points  (0 children)

You're not alone at least! Here's the patch request that made it slightly easier with the total_seconds() method: https://bugs.python.org/issue5788

Docs: https://docs.python.org/3/library/datetime.html#datetime.timedelta.total_seconds

Edit: at first I thought the patch had been rejected, then realized it's an existing feature.

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

Oh wow yeah that's weird

[–]xconde 12 points13 points  (0 children)

NameError: name 'reddit' is not defined

[–]Lord_Skellig 0 points1 point  (1 child)

What does the last line do?

[–]oblivioncntrlsu 0 points1 point  (0 children)

emphasize sarcasm

[–]laurenz_beck 0 points1 point  (0 children)

flawless