Rearrange example a bit, and show rpartition() when separator is not found

This commit is contained in:
Andrew M. Kuchling 2006-09-05 13:02:40 +00:00
parent c48c9e266f
commit a60b60e72e
1 changed files with 4 additions and 2 deletions

View File

@ -1115,12 +1115,14 @@ Some examples:
\begin{verbatim} \begin{verbatim}
>>> ('http://www.python.org').partition('://') >>> ('http://www.python.org').partition('://')
('http', '://', 'www.python.org') ('http', '://', 'www.python.org')
>>> (u'Subject: a quick question').partition(':')
(u'Subject', u':', u' a quick question')
>>> ('file:/usr/share/doc/index.html').partition('://') >>> ('file:/usr/share/doc/index.html').partition('://')
('file:/usr/share/doc/index.html', '', '') ('file:/usr/share/doc/index.html', '', '')
>>> (u'Subject: a quick question').partition(':')
(u'Subject', u':', u' a quick question')
>>> 'www.python.org'.rpartition('.') >>> 'www.python.org'.rpartition('.')
('www.python', '.', 'org') ('www.python', '.', 'org')
>>> 'www.python.org'.rpartition(':')
('', '', 'www.python.org')
\end{verbatim} \end{verbatim}
(Implemented by Fredrik Lundh following a suggestion by Raymond Hettinger.) (Implemented by Fredrik Lundh following a suggestion by Raymond Hettinger.)