Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 14382dc

Browse files
committed
Update documentation for shutil.move (#12043) and fix a few typos.
Adding Sandro Tosi to Doc/ACKS for this patch and all his work on the docs mailing list and on the bug tracker.
1 parent 2f834f2 commit 14382dc

2 files changed

Lines changed: 17 additions & 10 deletions

File tree

Doc/ACKS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ [email protected]), and we'll be glad to correct the problem.
203203
* Kalle Svensson
204204
* Jim Tittsler
205205
* David Turner
206+
* Sandro Tosi
206207
* Ville Vainio
207208
* Martijn Vries
208209
* Charles G. Waldman

Doc/library/shutil.rst

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -159,19 +159,25 @@ Directory and files operations
159159

160160
.. function:: move(src, dst)
161161

162-
Recursively move a file or directory to another location.
162+
Recursively move a file or directory (*src*) to another location (*dst*).
163163

164-
Uses :func:`os.rename` to perform the move. If it fails, for reasons such as
165-
when *src* and *dst* are on different filesystems or in case of windows where
166-
rename is not supported when *dst* exists, fallback to copying *src* (with
167-
:func:`copy2`) to the *dst* and then remove *src*.
164+
If the destination is a directory or a symlink to a directory, then *src* is
165+
moved inside that directory.
166+
167+
The destination directory must not already exist. If the destination already
168+
exists but is not a directory, it may be overwritten depending on
169+
:func:`os.rename` semantics.
170+
171+
If the destination is on the current filesystem, then :func:`os.rename` is
172+
used. Otherwise, *src* is copied (using :func:`copy2`) to *dst* and then
173+
removed.
168174

169175

170176
.. exception:: Error
171177

172-
This exception collects exceptions that raised during a multi-file operation. For
173-
:func:`copytree`, the exception argument is a list of 3-tuples (*srcname*,
174-
*dstname*, *exception*).
178+
This exception collects exceptions that are raised during a multi-file
179+
operation. For :func:`copytree`, the exception argument is a list of 3-tuples
180+
(*srcname*, *dstname*, *exception*).
175181

176182

177183
.. _shutil-example:
@@ -269,7 +275,7 @@ Archiving operations
269275

270276
.. function:: get_archive_formats()
271277

272-
Returns a list of supported formats for archiving.
278+
Return a list of supported formats for archiving.
273279
Each element of the returned sequence is a tuple ``(name, description)``
274280

275281
By default :mod:`shutil` provides these formats:
@@ -287,7 +293,7 @@ Archiving operations
287293

288294
.. function:: register_archive_format(name, function, [extra_args, [description]])
289295

290-
Registers an archiver for the format *name*. *function* is a callable that
296+
Register an archiver for the format *name*. *function* is a callable that
291297
will be used to invoke the archiver.
292298

293299
If given, *extra_args* is a sequence of ``(name, value)`` pairs that will be

0 commit comments

Comments
 (0)