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
f9b51b27
Commit
f9b51b27
authored
May 08, 2003
by
Greg Ward
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SF patch #598163 (Ville Vainio, vvainio@users.sourceforge.net):
document dedent() function.
parent
cfab04ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
4 deletions
+29
-4
Doc/lib/libtextwrap.tex
Doc/lib/libtextwrap.tex
+29
-4
No files found.
Doc/lib/libtextwrap.tex
View file @
f9b51b27
...
...
@@ -10,10 +10,10 @@
The
\module
{
textwrap
}
module provides two convenience functions,
\function
{
wrap()
}
and
\function
{
fill()
}
, as well as
\class
{
TextWrapper
}
, the class that does all the work
. If you're just
wrapping or filling one or two text strings, the convenience functions
should be good enough; otherwise, you should use an instance of
\class
{
TextWrapper
}
for efficiency.
\class
{
TextWrapper
}
, the class that does all the work
, and a utility function
\function
{
dedent()
}
. If you're just wrapping or filling one or two
text strings, the convenience functions should be good enough; otherwise,
you should use an instance of
\class
{
TextWrapper
}
for efficiency.
\begin{funcdesc}
{
wrap
}{
text
\optional
{
, width
\optional
{
,
\moreargs
}}}
Wraps the single paragraph in
\var
{
text
}
(a string) so every line is at
...
...
@@ -42,6 +42,31 @@ instance is not reused, so for applications that wrap/fill many text
strings, it will be more efficient for you to create your own
\class
{
TextWrapper
}
object.
An additional utility function,
\function
{
dedent()
}
, is provided to
remove indentation from strings that have unwanted whitespace to the
left of the text.
\begin{funcdesc}
{
dedent
}{
text
}
Remove any whitespace than can be uniformly removed from the left
of every line in
\var
{
text
}
.
This is typically used to make triple-quoted strings line up with
the left edge of screen/whatever, while still presenting it in the
source code in indented form.
For example:
\begin{verbatim}
def test():
# end first line with
\
to avoid the empty line!
s = '''
\
Hey
there
'''
print repr(s) # prints ' Hey
\n
there
\n
'
print repr(dedent(s)) # prints 'Hey
\nthere\n
'
\end{verbatim}
\end{funcdesc}
\begin{classdesc}
{
TextWrapper
}{
...
}
The
\class
{
TextWrapper
}
constructor accepts a number of optional
keyword arguments. Each argument corresponds to one instance attribute,
...
...
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