Off topic, what's the font name? I think Jonathon Blow (designer and programmer of Braid and The Witness) also uses this font and I never knew it's name.
This smells strongly of Stack-Overflow-driven development. Google "python delay", copy the code block everywhere you want a delay, and ask no questions.
Nah someone already made a package that automatically finds, parses and compiles python code in stackoverflow answer and returns it as a function. Just install pip3 install stackoverflow
I don't care if it uses multiple imports all over the place. Eventually, I'm going to delete them of course.
As for the code in question: must be some QA script monkey writing something that would bore everyone to death, and just couldn't be arsed to remove the copy-paste artifacts, because nobody really cares anyways.
It's indeed a QA-looking script (Selenium, web browser automation).
Using static sleeps is common and objectively bad in that context even without the multiple imports. You can and should wait on specific conditions (element is visible, etc.) instead, but static sleeps are a common lazy approach.
Man, let me kindly ask you, what do you do, when your dynamic or specific waits are failing, like, I have a sanity test script ( I am a DevOps engineer ) that runs after deployment, but I had to put this ugly waits, and not low waits, high ones, like 15 20 seconds almost after every action, because custom waits timeout, even if I put them 15-20 seconds in the settings, it gives at the 3d second a timeout exception or not found exception, the only solution I found are this ugly waits, not to mention I have some Js being executed, and if I don't put them I get element[0] of undefined xD
I should have a blog post or something for this haha.
Basically what I tell my team is "What are you trying to wait for? Now that you know, programmatically wait for that".
It sounds like you might have other issues you're fighting though, e.g. regarding the element not found exception while waiting. I generally write my own waiter helpers (I have a whole open source framework for this and much more) that don't run into common gotchas and actually do the whole wait.
If you're timing out with even massive waits, if this is an end-user application, I tend to recommend raising it as a user experience bug. Users shouldn't have to wait for 30+ seconds as an expected operation. If it's truly a long running task, the design of the page/workflow should reflect that (and maybe you're waiting on an email or something instead, for example).
I'm not sure that helps at all, there's a lot to cover and a lot of gotchas!
I believe the (I don't remember what it' was called) html module scraper has a built in system to wait for a Web page to load and then scrape the data once loaded rather than using import time.
I mean, you can find plenty of bad C or C++ or Rust code, but I don't think there's a WHOLE lot out there that is done BECAUSE the compiler's optimizer MIGHT remove it.
its more of a question of the mindset. the temptation to not care would be larger when using a inherently fast language, or one with a compiler that optimizes a lot.
its like, i have caught myself not caring about a extra loop which wasn't needed when using a fast compiled language.
IMO you shouldn't care about that loop until you've profiled your code and are working on optimization.
Trying to micro-optimize compiled code before you know what parts are slow is silly; focusing on writing clean and readable code is a better use of your time.
TL;DR: Unless you are writing a function that you know is going to be called a million times, it's okay to not hand-unroll your loops.
11
u/heyshikhar Jan 04 '22
Off topic, what's the font name? I think Jonathon Blow (designer and programmer of Braid and The Witness) also uses this font and I never knew it's name.
291
u/TinyBreadBigMouth Jan 04 '22
This smells strongly of Stack-Overflow-driven development. Google "python delay", copy the code block everywhere you want a delay, and ask no questions.
33
u/BabyPuncher3000 Jan 04 '22
Pardon me, do you have the time?
31
u/MediocreConfused Jan 04 '22 edited Jan 04 '22
Image Transcription: Code
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
56
u/teefj Jan 04 '22
while (true) import time
22
u/qwazwak Jan 04 '22
This
import time
hurts
8
u/government_shill Jan 04 '22
This is how you get extra time to finish the project.
5
u/ycastor Jan 04 '22
Stop! Import time. Ding ding ding.
3
u/[deleted] Jan 04 '22
Idk. I just have an abbrev that expands to:
I don't care if it uses multiple imports all over the place. Eventually, I'm going to delete them of course.
As for the code in question: must be some QA script monkey writing something that would bore everyone to death, and just couldn't be arsed to remove the copy-paste artifacts, because nobody really cares anyways.
3
u/[deleted] Jan 04 '22
You know what time it is??
3
u/rymdsylt Jan 04 '22
This is an old version of Python when imports clearly only were a one time use.
2
u/[deleted] Jan 04 '22
y not from time import sleep?
2
u/b0ogi3 Jan 04 '22
Rule no 1 of UI automation. Never sleep. Ever.
1
u/[deleted] Jan 04 '22
Incredible
1
u/nupanick Jan 05 '22
from stackoverflow import stacksort
1
u/HarryCoder123 Jan 06 '22
My guy is the god of inefficiency
1
u/New-Secretary-666 Jan 09 '22
I believe the (I don't remember what it' was called) html module scraper has a built in system to wait for a Web page to load and then scrape the data once loaded rather than using import time.
0
u/[deleted] Jan 04 '22
[deleted] — view deleted comment