title: getting directory size of subdirectory in python
body: <p>I have a directory that I am walking with multiple subdirectories in it and possibly subdirectories within the subdirectories.</p>
  
  <pre><code>Folder
  +-Sub1
  | +-SubSub1
  | +-File1
  +-Sub2
  | +-File2
  +-Sub3
  | +-File3
  | +-File4
  +-Sub4
    +-File5
    +-SubSub2
      +-File6
  </code></pre>
  
  <p>I would like to get the size of each subfolder (Sub1, Sub2, etc) in it's entirety. I also need to get the name of each folder. For example:</p>
  
  <pre><code>Sub1 is 34 MB
  Sub2 is 2893 MB
  ...
  </code></pre>
  
  <p>I currently have the following:</p>
  
  <pre><code>for r, d, f in os.walk(directory):
      size = sum(getsize(join(r,n)) for n in f) / 1048576
      print size
      for s in d:
          print s
  </code></pre>
  
  <p>which prints out all the sizes followed by all of the directory names because they are each in separate for loops. How can I print it as stated above?</p>