I have this code:
for infile in glob.glob(os.path.join(path, '*')):
out.add(infile)
file.write('\File added:' + infile)
Out is a variable for the locations of a tarfile. I'm adding files to it. When complete, it adds folder hierarchy as well as the files. I just want to add the files so that when I untar it, I don't have to dig through a bunch of folders to get to the files. Can anyone clue me in on how to do that?
Posts
Thanks for the info on strings too. This is my first shot at doing something in python, and you've made my life a little easier.
If he is using either Python 2.6+ or Python 3.x, then he shouldn't be using that. Instead he should be using the string's format method:
If no format specifier is given it defaults to a given object's str() representation. If you like you can use an int to specify a positional argument, or a string for a named argument:
For more see the docs, particularly the sections Format String Syntax and Format Specification Mini-Language.
Yeah, this is probably the case for what you should do these days. Just about anything is better than 'foo' + bar, though.
Anyway, PEP-8 is your friend, as well:
http://www.python.org/dev/peps/pep-0008/