How to stop python recursion -


i made function searches files recursively , want stop recursion when first file found:

def search_file(path):     name in os.listdir(path):         sub = os.path.join(path, name)         if os.path.isfile(sub):             return sub#and break recursion         else:             search_file(sub) 

return flag says whether file found. when call search_file, return if return value true.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -