[Tutor] tarfile library question
Alan Gauld
alan.gauld at yahoo.co.uk
Fri Dec 11 04:36:36 EST 2020
On 11/12/2020 00:12, alexkleider via Tutor wrote:
>> Probably. You need a loop over the target folders somewhere
>> inside the open
> def archive(destination_directory, source, targz_base_name):
with .... as tar:
> for folder in list_of_targets:
tar.add(folder)
> res = shutil.move(tar_file, destination_directory)
> if not (repr(res) == repr(os.path.join(destination_directory,
> print("...should be the same: something went wrong!")
Should work?
You still don't tell us where list_of_targets comes from?
It's not in the function so presumably is a global, which
is not a good idea... Or is it a typo and it should
be the "source" parameter?
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list