Forum Archive

While True is True :

donnieh

Is it bad practice to use a forever loop in pythonista? I ask because I used the def download_file function from the omz dropbox file picker script in my own script. It worked great except once my program completed it's start up code and entered the while loop, I had issues with the downloaded file.

If I downloaded a file using omz's DropBox script in the while loop and then tried to read it using f = open('file_name') outside the while loop, it would not read or see the file. Can I only read the file in the same scope I downloaded it? I could open it inside the while loop, however.

ccc

The trick is that you have to have a break or sys.exit() or similar somewhere in that loop or your device is going to churn until its batteries run out. Computers are still very literal.

Oh, and... while True: is sufficient to start an infinite loop.