os walk with changed directory structure
<p>i currently want to improve a python script I wrote once.</p>

<p>In it the structure is roughly like this:</p>

<pre><code>def x(args):
    for root, dirs, files in os.walk(args):
        do_something_that_changes_the_directory_structure()

    for root, dirs, files in os.walk(args):
        do_someting_with_that_changed_directory()
</code></pre>

<p>The problem is that i change the directory structure and have to re-read that structure to do something with it. Is it possible to do this with only one for loop? I thougth about while loops but after thinking about it I don't think that works!</p>
