File tree Expand file tree Collapse file tree 1 file changed +15
-15
lines changed
Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -1325,6 +1325,21 @@ How to read a gzip compressed tar archive and display some member information::
13251325Writing examples
13261326~~~~~~~~~~~~~~~~
13271327
1328+ How to create an uncompressed tar archive from a list of filenames::
1329+
1330+ import tarfile
1331+ tar = tarfile.open("sample.tar", "w")
1332+ for name in ["foo", "bar", "quux"]:
1333+ tar.add(name)
1334+ tar.close()
1335+
1336+ The same example using the :keyword: `with ` statement::
1337+
1338+ import tarfile
1339+ with tarfile.open("sample.tar", "w") as tar:
1340+ for name in ["foo", "bar", "quux"]:
1341+ tar.add(name)
1342+
13281343How to create and write an archive to stdout using
13291344:data: `sys.stdout.buffer <sys.stdout> ` in the *fileobj * parameter
13301345in :meth: `TarFile.add `::
@@ -1347,21 +1362,6 @@ parameter in :meth:`TarFile.add`::
13471362 tar.add("foo", filter=reset)
13481363 tar.close()
13491364
1350- How to create an uncompressed tar archive from a list of filenames::
1351-
1352- import tarfile
1353- tar = tarfile.open("sample.tar", "w")
1354- for name in ["foo", "bar", "quux"]:
1355- tar.add(name)
1356- tar.close()
1357-
1358- The same example using the :keyword: `with ` statement::
1359-
1360- import tarfile
1361- with tarfile.open("sample.tar", "w") as tar:
1362- for name in ["foo", "bar", "quux"]:
1363- tar.add(name)
1364-
13651365.. _tar-formats :
13661366
13671367Supported tar formats
You can’t perform that action at this time.
0 commit comments