Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
60de2e83
Commit
60de2e83
authored
Mar 12, 2003
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SF bug #699237: Tutorial uses omitted slice indices before explaining them
Moved up the explanation of slice default arguments.
parent
83245b58
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
Doc/tut/tut.tex
Doc/tut/tut.tex
+11
-11
No files found.
Doc/tut/tut.tex
View file @
60de2e83
...
...
@@ -640,6 +640,17 @@ separated by a colon.
'lp'
\end{verbatim}
Slice indices have useful defaults; an omitted first index defaults to
zero, an omitted second index defaults to the size of the string being
sliced.
\begin{verbatim}
>>> word[:2] # The first two characters
'He'
>>> word[2:] # All but the first two characters
'lpA'
\end{verbatim}
Unlike a C string, Python strings cannot be changed. Assigning to an
indexed position in the string results in an error:
...
...
@@ -664,17 +675,6 @@ efficient:
'SplatA'
\end{verbatim}
Slice indices have useful defaults; an omitted first index defaults to
zero, an omitted second index defaults to the size of the string being
sliced.
\begin{verbatim}
>>> word[:2] # The first two characters
'He'
>>> word[2:] # All but the first two characters
'lpA'
\end{verbatim}
Here's a useful invariant of slice operations:
\code
{
s[:i] + s[i:]
}
equals
\code
{
s
}
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment