File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -559,14 +559,18 @@ Pure paths provide the following methods and properties:
559559.. method :: PurePath.with_suffix(suffix)
560560
561561 Return a new path with the :attr: `suffix ` changed. If the original path
562- doesn't have a suffix, the new *suffix * is appended instead::
562+ doesn't have a suffix, the new *suffix * is appended instead. If the
563+ *suffix * is an empty string, the original suffix is removed::
563564
564565 >>> p = PureWindowsPath('c:/Downloads/pathlib.tar.gz')
565566 >>> p.with_suffix('.bz2')
566567 PureWindowsPath('c:/Downloads/pathlib.tar.bz2')
567568 >>> p = PureWindowsPath('README')
568569 >>> p.with_suffix('.txt')
569570 PureWindowsPath('README.txt')
571+ >>> p = PureWindowsPath('README.txt')
572+ >>> p.with_suffix('')
573+ PureWindowsPath('README')
570574
571575
572576.. _concrete-paths :
Original file line number Diff line number Diff line change @@ -807,8 +807,10 @@ def with_name(self, name):
807807 self ._parts [:- 1 ] + [name ])
808808
809809 def with_suffix (self , suffix ):
810- """Return a new path with the file suffix changed (or added, if none)."""
811- # XXX if suffix is None, should the current suffix be removed?
810+ """Return a new path with the file suffix changed. If the path
811+ has no suffix, add given suffix. If the given suffix is an empty
812+ string, remove the suffix from the path.
813+ """
812814 f = self ._flavour
813815 if f .sep in suffix or f .altsep and f .altsep in suffix :
814816 raise ValueError ("Invalid suffix %r" % (suffix ))
You can’t perform that action at this time.
0 commit comments