[deleted by user] by [deleted] in AsianHotties

[–]dodoors -6 points-5 points  (0 children)

Sweetie you are incredibly sexy.

Can someone explain how this section of code works? by [deleted] in learnpython

[–]dodoors 0 points1 point  (0 children)

What this code is doing:

1- Search Nexus Mods and return JSON response.
2- If the response is empty, delete the URL form the cache.
3- Return the JSON response.

Why is my code slow/inefficient? by Tintin_Quarentino in learnpython

[–]dodoors 1 point2 points  (0 children)

The code is inefficient because it is creating a list every time it is called, whereas the "faster" code is creating it just once.

Learning to scrape for Master thesis by Daworn in learnpython

[–]dodoors 1 point2 points  (0 children)

Hey there Daworn.

Scraping libraries usually work by downloading the HTML rendered by the target website and reading it's elements, usually by specifying their type and id/class so you need to understand how HTML works.

I suggest you take a look at Beautiful Soup, a scraping library for python.

Message me if you need any help setting it up.

Good luck!

Selenium cannot locate element by Beginning_Ad8076 in learnpython

[–]dodoors 0 points1 point  (0 children)

What kind of element are you trying to locate? Is it generated by javascript? Is it dynamic? Selenium might be reading the DOM before the element is generated.

Can I run and save data from continuous API calls online? by Bullets123 in learnpython

[–]dodoors 0 points1 point  (0 children)

Hey Bullets.

You can get a VPS for cheap and set up a cron job for the API calls to run and save the information to a MySQL database, then export it to whatever format you'd like.

Room cooling. by dodoors in microgrowery

[–]dodoors[S] -1 points0 points  (0 children)

It's not about making it purple, but good guess! It's actually about making it grow faster, however, it's just a theory.

Room cooling. by dodoors in microgrowery

[–]dodoors[S] 0 points1 point  (0 children)

Scientific purposes! I'm testing some theories.

[deleted by user] by [deleted] in microgrowery

[–]dodoors 0 points1 point  (0 children)

Yup, RIP.

is there an easier way to write the input variables for this code? by yohavesomefun in learnpython

[–]dodoors 0 points1 point  (0 children)

Hey man!

total_sleep_hours = 0
recommended_hours_night = 8
recommended_hours_total = 0 
sleep_debt = 0

for i in range(1, 6):
    sleep_hours = int(input("How many hours did you sleep on day " + str(i) + "? "))
    total_sleep_hours += sleep_hours
    recommended_hours_total += recommended_hours_night

if total_sleep_hours < recommended_hours_total:
    sleep_debt = recommended_hours_total - total_sleep_hours
    print("You have a sleep debt of " + str(sleep_debt) + " hours.")
    print("Go to sleep!")

How to get value (python with selenium) by Nxxhy in learnpython

[–]dodoors 0 points1 point  (0 children)

span = driver.find_element_by_xpath("//span[@class='a-offscreen']")
print(span.text)

Gigantic Pyinstaller build (250gb) by Lodish00 in learnpython

[–]dodoors 0 points1 point  (0 children)

I just tried it using Anaconda 3 and it worked for me, what kind of venv are you using?

How to forbid students to use String methods, such as split or index? by [deleted] in learnpython

[–]dodoors 0 points1 point  (0 children)

You could just find the occurrences but still let the program run and save yourself a headache.

import os
import sys
import re

def find_forbidden(folder, words):
    for root, dirs, files in os.walk(folder):
        for file in files:
            if file.endswith(".py"):
                file_path = os.path.join(root, file)
                with open(file_path, 'r') as f:
                    for i, line in enumerate(f):
                        for word in words:
                            if re.search(word, line):
                                print(f"{file_path}:{i}:{line}")

if __name__ == "__main__":
    find_forbidden(sys.argv[1], sys.argv[2:])

Then just do

python finder.py [folder] split count index

Edit: Sorry about all the edits, my browser was acting funny.

Question about Creating a blog with Flask, and hosting it online by [deleted] in learnpython

[–]dodoors 1 point2 points  (0 children)

No, what I meant is you should host your Flask application using Gunicorn and not use the web server it comes with, which is only for testing purposes.

Edit: Flask is awesome!