[Tutor] tarfile library question
alexkleider
alexkleider at protonmail.com
Fri Dec 11 09:55:19 EST 2020
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, December 11, 2020 1:36 AM, Alan Gauld via Tutor <tutor at python.org> wrote:
> 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?
>
Oops!
Yes, it should have been "source" (which needs to be a list of target directories &/or files.)
Apologies again.
a
More information about the Tutor
mailing list