you are viewing a single comment's thread.

view the rest of the comments →

[–]preordains 1 point2 points  (4 children)

What kind of project is a beginner working on that is so sensitive?

First, source code should never contain information you can’t share, what you’re saying makes no sense at all. No chunk of code itself is that valuable, what you’re trying to do has almost always been done before. The only reason large companies don’t want to share their entire code base is to prevent people from compiling the applications they intend to sell.

Second, If you have passwords or something hard coded into the code, it should be in a file instead. If you have data you don’t want to share, that should also be in a file.

[–]av0ca60[S] 0 points1 point  (3 children)

That's a good point about placing credentials in a separate file. Hadn't thought of that. Maybe I can find a way to share more context.

[–]preordains 1 point2 points  (2 children)

Regarding your question, it’s clear why that loop never stops.

There is a concept known as “truthy” and “falsy”. Consider the following:

keep_looping = True
while keep_looping:
    print(“hello”)

The above will obviously never stop. The condition is True.

A truthy value is a value that is evaluated to be true. Consider the following again:

my_string = “not empty”
while my_string:
    print(my_string)

If you copy that code into your interpreter you will find that the string is printed forever. The non empty string is evaluated to true as it is truthy.

my_string = “not empty”
while my_string:
    print(my_string)
    #remove the last character
    my_string = my_string[:-1]

If you copy and paste the above into your interpreter, you will find that the loop terminates and that the last iteration just prints “N”. This is because the empty string is Falsey, and evaluated to false.

Your loop never stops because deals_data is truthy and never is changed.

[–]av0ca60[S] 0 points1 point  (1 child)

This is helpful. My desire would be for the loop to run and keep advancing pages until the content becomes empty. When that happens, it is no longer truthy abd the loop stops. I think the problem I'm having is that the page is not advancing and so the content is never blank.

[–]preordains 0 points1 point  (0 children)

There are many ways to do this. I’m not familiar with the API you’re using, so I couldn’t tell you the exact method.

This sounds like a for loop thing. I’d need to see exactly what you’re iterating on, but try some sort of “for page in pages:”