![]() |
| ||
| can't figure out loop ############################################################################I need a way to make this loop until it doesn't find any file in any directory.... I can't figure out how to make it do that. |
| ||
| Re: can't figure out loop Perhaps add near the start of main(): found = Falseand add the last line to this sequence: print "File found -->", trueResult ... and change return True at the end of main() to return found.So found starts out "False" meaning "none found" and gets set to "True" when anything is found. A "True" return from main() is interpreted as "not done, call me again". I'd also change the loop at the bottom to be more like: while main(): I'm not quite sure why a single pass doesn't do the trick, but that's not my business. |
| ||
| Re: can't figure out loop i'm helping an admin of a network where the users put starcraft everwhere and anywhere, and rename the folders, and have it in more than one place at once. so i need it to run until its found everywhere they hid it and wipe out the critical files. |
| ||
| Re: can't figure out loop LOL. Net administration is like cat-herding. Here's a possibility for you: Starcraft won't run if the user doesn't have admin rights... Just a thought. :) Anyways, consider these two methods: for file in file_list:vs. for file in entire_file_system: From a theoretical point of view, both are equally time-consuming. But practically, the second one wins hands-down because you are only traversing the file system once, which requires a lot of hard-drive access time. AND, the second one is easier to code. def main(): I left out the counter and most of the logging, but that's the gist. |
| All times are GMT -4. The time now is 2:57 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC