Excluding directories from tarfile module
<p>I am trying to tar the contents of a directory using the tarfile module.</p>

<p>Say this directory, called 'A', has several subdirectories, 'a' and 'a1' etc...
Is there a way to exclude these directories from the tarfile object when trying to add?
For example, I have a list of files to exclude, which I put in the list:</p>

<pre><code>EXCLUDE_FILES = ['README', '.gitignore']
</code></pre>

<p>I can exclude these following a <a href="https://stackoverflow.com/questions/16000794/python-tarfile-and-excludes">solution</a> found here. However, can this method be altered to exclude directories or is there another way in which it can be done?</p>