Skip to content

Commit 84fabe0

Browse files
Conform with previous examples
1 parent d1f942b commit 84fabe0

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Doc/library/tarfile.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,16 +1346,15 @@ parameter in :meth:`TarFile.add`::
13461346
tar.add("foo", filter=reset)
13471347
tar.close()
13481348

1349-
How to create and write the archive to stdout using
1349+
How to create and write an archive to stdout using
13501350
:data:`sys.stdout.buffer <sys.stdout>` in the *fileobj* parameter
13511351
in :meth:`TarFile.add`::
13521352

1353-
import tarfile
13541353
import sys
1355-
files = ["foo.txt", "bar.txt", "quux.txt"]
1356-
with tarfile.open("sample.tar.gz", "w|gz", fileobj=sys.stdout.buffer) as tar:
1357-
for file in files:
1358-
tar.add(file)
1354+
import tarfile
1355+
with tarfile.open("sample.tar.gz", "w:gz", fileobj=sys.stdout.buffer) as tar:
1356+
for name in ["foo", "bar", "quux"]:
1357+
tar.add(name)
13591358

13601359
.. _tar-formats:
13611360

0 commit comments

Comments
 (0)