title: pythonic way to access each file in a list of directories
body: <p>I have working code that looks like this:</p>
  
  <pre><code># Wow. Much nesting. So spacebar
  if __name__ == '__main__:
    for eachDir in list_of_unrelated_directories:
        for eachFile in os.listdir(eachDir):
            if eachFile.endswith('.json'):
              # do stuff here
  </code></pre>
  
  <p>I'd like to know if there is a more elegant way of doing that. I would like to not have my code nested three layers deep like that, and if I could get this to a one-liner like</p>
  
  <pre><code>for each file that ends with .json in all these directories:
    # do stuff
  </code></pre>
  
  <p>That would be even more awesome. I also edited this to point out that the directories are not all in the same folder. Like you might be looking for .json files in your home folder and also your /tmp folder. So I'm not trying to move recursively through a single folder.</p>