blob: 192b43b1df9459f2bc183637b1a3b3197661427e [file] [log] [blame]
Greg Warde807e572002-07-04 14:51:49 +00001"""Text wrapping and filling.
Greg Ward00935822002-06-07 21:43:37 +00002"""
3
Greg Ward78cc0512002-10-13 19:23:18 +00004# Copyright (C) 1999-2001 Gregory P. Ward.
Greg Ward523008c2003-06-15 15:37:18 +00005# Copyright (C) 2002, 2003 Python Software Foundation.
Greg Ward698d9f02002-06-07 22:40:23 +00006# Written by Greg Ward <gward@python.net>
7
Greg Ward00935822002-06-07 21:43:37 +00008__revision__ = "$Id$"
9
10import string, re
11
Greg Ward523008c2003-06-15 15:37:18 +000012# Do the right thing with boolean values for all known Python versions
13# (so this module can be copied to projects that don't depend on Python
Brett Cannon791ec1f2008-08-01 01:34:05 +000014# 2.3, e.g. Optik and Docutils) by uncommenting the block of code below.
15#try:
16# True, False
17#except NameError:
18# (True, False) = (1, 0)
Greg Ward523008c2003-06-15 15:37:18 +000019
Georg Brandl3129ea22008-12-05 11:34:51 +000020__all__ = ['TextWrapper', 'wrap', 'fill', 'dedent']
Greg Ward4c6c9c42003-02-03 14:46:57 +000021
Greg Wardafd44de2002-12-12 17:24:35 +000022# Hardcode the recognized whitespace characters to the US-ASCII
23# whitespace characters. The main reason for doing this is that in
24# ISO-8859-1, 0xa0 is non-breaking whitespace, so in certain locales
25# that character winds up in string.whitespace. Respecting
26# string.whitespace in those cases would 1) make textwrap treat 0xa0 the
27# same as any other whitespace char, which is clearly wrong (it's a
28# *non-breaking* space), 2) possibly cause problems with Unicode,
29# since 0xa0 is not in range(128).
Greg Ward4c6c9c42003-02-03 14:46:57 +000030_whitespace = '\t\n\x0b\x0c\r '
Greg Wardafd44de2002-12-12 17:24:35 +000031
Greg Ward00935822002-06-07 21:43:37 +000032class TextWrapper:
33 """
34 Object for wrapping/filling text. The public interface consists of
35 the wrap() and fill() methods; the other methods are just there for
36 subclasses to override in order to tweak the default behaviour.
37 If you want to completely replace the main wrapping algorithm,
38 you'll probably have to override _wrap_chunks().
39
Greg Wardd34c9592002-06-10 20:26:02 +000040 Several instance attributes control various aspects of wrapping:
41 width (default: 70)
42 the maximum width of wrapped lines (unless break_long_words
43 is false)
Greg Ward62080be2002-06-10 21:37:12 +000044 initial_indent (default: "")
45 string that will be prepended to the first line of wrapped
46 output. Counts towards the line's width.
47 subsequent_indent (default: "")
48 string that will be prepended to all lines save the first
49 of wrapped output; also counts towards each line's width.
Greg Ward62e4f3b2002-06-07 21:56:16 +000050 expand_tabs (default: true)
51 Expand tabs in input text to spaces before further processing.
52 Each tab will become 1 .. 8 spaces, depending on its position in
53 its line. If false, each tab is treated as a single character.
54 replace_whitespace (default: true)
55 Replace all whitespace characters in the input text by spaces
56 after tab expansion. Note that if expand_tabs is false and
57 replace_whitespace is true, every tab will be converted to a
58 single space!
59 fix_sentence_endings (default: false)
60 Ensure that sentence-ending punctuation is always followed
Andrew M. Kuchlinga2ecabe2003-02-14 01:14:15 +000061 by two spaces. Off by default because the algorithm is
Greg Ward62e4f3b2002-06-07 21:56:16 +000062 (unavoidably) imperfect.
63 break_long_words (default: true)
Greg Wardd34c9592002-06-10 20:26:02 +000064 Break words longer than 'width'. If false, those words will not
65 be broken, and some lines might be longer than 'width'.
Georg Brandl6f95ae52008-05-11 10:42:28 +000066 break_on_hyphens (default: true)
67 Allow breaking hyphenated words. If true, wrapping will occur
68 preferably on whitespaces and right after hyphens part of
69 compound words.
Georg Brandl9e6b4702007-03-13 18:15:41 +000070 drop_whitespace (default: true)
71 Drop leading and trailing whitespace from lines.
Greg Ward00935822002-06-07 21:43:37 +000072 """
73
Greg Ward4c6c9c42003-02-03 14:46:57 +000074 whitespace_trans = string.maketrans(_whitespace, ' ' * len(_whitespace))
Greg Ward00935822002-06-07 21:43:37 +000075
Greg Ward2e745412002-12-09 16:23:08 +000076 unicode_whitespace_trans = {}
Greg Ward0e88c9f2002-12-11 13:54:20 +000077 uspace = ord(u' ')
Greg Ward4c6c9c42003-02-03 14:46:57 +000078 for x in map(ord, _whitespace):
Greg Ward0e88c9f2002-12-11 13:54:20 +000079 unicode_whitespace_trans[x] = uspace
Greg Ward2e745412002-12-09 16:23:08 +000080
Tim Petersc411dba2002-07-16 21:35:23 +000081 # This funky little regex is just the trick for splitting
Greg Ward00935822002-06-07 21:43:37 +000082 # text up into word-wrappable chunks. E.g.
83 # "Hello there -- you goof-ball, use the -b option!"
84 # splits into
85 # Hello/ /there/ /--/ /you/ /goof-/ball,/ /use/ /the/ /-b/ /option!
86 # (after stripping out empty strings).
Antoine Pitrou74af3bb2008-12-13 23:12:30 +000087 wordsep_re = (
Greg Ward40407942005-03-05 02:53:17 +000088 r'(\s+|' # any whitespace
Antoine Pitrou74af3bb2008-12-13 23:12:30 +000089 r'[^\s\w]*\w+[^0-9\W]-(?=\w+[^0-9\W])|' # hyphenated words
Greg Ward40407942005-03-05 02:53:17 +000090 r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash
Greg Ward00935822002-06-07 21:43:37 +000091
Georg Brandl6f95ae52008-05-11 10:42:28 +000092 # This less funky little regex just split on recognized spaces. E.g.
93 # "Hello there -- you goof-ball, use the -b option!"
94 # splits into
95 # Hello/ /there/ /--/ /you/ /goof-ball,/ /use/ /the/ /-b/ /option!/
Antoine Pitrou74af3bb2008-12-13 23:12:30 +000096 wordsep_simple_re = r'(\s+)'
Georg Brandl6f95ae52008-05-11 10:42:28 +000097
Greg Ward61864102004-06-03 01:59:41 +000098 # XXX this is not locale- or charset-aware -- string.lowercase
99 # is US-ASCII only (and therefore English-only)
Greg Ward9b4864e2002-06-07 22:04:15 +0000100 sentence_end_re = re.compile(r'[%s]' # lowercase letter
101 r'[\.\!\?]' # sentence-ending punct.
102 r'[\"\']?' # optional end-of-quote
Mark Dickinsonfe536f52008-04-25 16:59:09 +0000103 r'\Z' # end of chunk
Greg Ward9b4864e2002-06-07 22:04:15 +0000104 % string.lowercase)
Greg Ward62e4f3b2002-06-07 21:56:16 +0000105
Greg Ward00935822002-06-07 21:43:37 +0000106
Greg Wardf0ba7642004-05-13 01:53:10 +0000107 def __init__(self,
108 width=70,
109 initial_indent="",
110 subsequent_indent="",
111 expand_tabs=True,
112 replace_whitespace=True,
113 fix_sentence_endings=False,
Georg Brandl9e6b4702007-03-13 18:15:41 +0000114 break_long_words=True,
Georg Brandl6f95ae52008-05-11 10:42:28 +0000115 drop_whitespace=True,
116 break_on_hyphens=True):
Greg Wardd34c9592002-06-10 20:26:02 +0000117 self.width = width
Greg Ward62080be2002-06-10 21:37:12 +0000118 self.initial_indent = initial_indent
119 self.subsequent_indent = subsequent_indent
Greg Ward47df99d2002-06-09 00:22:07 +0000120 self.expand_tabs = expand_tabs
121 self.replace_whitespace = replace_whitespace
122 self.fix_sentence_endings = fix_sentence_endings
123 self.break_long_words = break_long_words
Georg Brandl9e6b4702007-03-13 18:15:41 +0000124 self.drop_whitespace = drop_whitespace
Georg Brandl6f95ae52008-05-11 10:42:28 +0000125 self.break_on_hyphens = break_on_hyphens
Tim Petersc411dba2002-07-16 21:35:23 +0000126
Greg Ward00935822002-06-07 21:43:37 +0000127
128 # -- Private methods -----------------------------------------------
129 # (possibly useful for subclasses to override)
130
Greg Wardcb320eb2002-06-07 22:32:15 +0000131 def _munge_whitespace(self, text):
Greg Ward00935822002-06-07 21:43:37 +0000132 """_munge_whitespace(text : string) -> string
133
134 Munge whitespace in text: expand tabs and convert all other
135 whitespace characters to spaces. Eg. " foo\tbar\n\nbaz"
136 becomes " foo bar baz".
137 """
138 if self.expand_tabs:
139 text = text.expandtabs()
140 if self.replace_whitespace:
Greg Ward2e745412002-12-09 16:23:08 +0000141 if isinstance(text, str):
142 text = text.translate(self.whitespace_trans)
143 elif isinstance(text, unicode):
144 text = text.translate(self.unicode_whitespace_trans)
Greg Ward00935822002-06-07 21:43:37 +0000145 return text
146
147
Greg Wardcb320eb2002-06-07 22:32:15 +0000148 def _split(self, text):
Greg Ward00935822002-06-07 21:43:37 +0000149 """_split(text : string) -> [string]
150
151 Split the text to wrap into indivisible chunks. Chunks are
152 not quite the same as words; see wrap_chunks() for full
153 details. As an example, the text
154 Look, goof-ball -- use the -b option!
155 breaks into the following chunks:
156 'Look,', ' ', 'goof-', 'ball', ' ', '--', ' ',
157 'use', ' ', 'the', ' ', '-b', ' ', 'option!'
Georg Brandl6f95ae52008-05-11 10:42:28 +0000158 if break_on_hyphens is True, or in:
159 'Look,', ' ', 'goof-ball', ' ', '--', ' ',
160 'use', ' ', 'the', ' ', '-b', ' ', option!'
161 otherwise.
Greg Ward00935822002-06-07 21:43:37 +0000162 """
Antoine Pitrou74af3bb2008-12-13 23:12:30 +0000163 flags = re.UNICODE if isinstance(text, unicode) else 0
164 if self.break_on_hyphens:
165 pat = self.wordsep_re
Georg Brandl6f95ae52008-05-11 10:42:28 +0000166 else:
Antoine Pitrou74af3bb2008-12-13 23:12:30 +0000167 pat = self.wordsep_simple_re
168 chunks = re.compile(pat, flags).split(text)
Georg Brandl9e6b4702007-03-13 18:15:41 +0000169 chunks = filter(None, chunks) # remove empty chunks
Greg Ward00935822002-06-07 21:43:37 +0000170 return chunks
171
Greg Wardcb320eb2002-06-07 22:32:15 +0000172 def _fix_sentence_endings(self, chunks):
Greg Ward00935822002-06-07 21:43:37 +0000173 """_fix_sentence_endings(chunks : [string])
174
175 Correct for sentence endings buried in 'chunks'. Eg. when the
176 original text contains "... foo.\nBar ...", munge_whitespace()
177 and split() will convert that to [..., "foo.", " ", "Bar", ...]
178 which has one too few spaces; this method simply changes the one
179 space to two.
180 """
181 i = 0
Greg Ward9b4864e2002-06-07 22:04:15 +0000182 pat = self.sentence_end_re
Greg Ward00935822002-06-07 21:43:37 +0000183 while i < len(chunks)-1:
Greg Ward9b4864e2002-06-07 22:04:15 +0000184 if chunks[i+1] == " " and pat.search(chunks[i]):
Greg Ward00935822002-06-07 21:43:37 +0000185 chunks[i+1] = " "
186 i += 2
187 else:
188 i += 1
189
Raymond Hettinger8bfa8932005-07-15 06:53:35 +0000190 def _handle_long_word(self, reversed_chunks, cur_line, cur_len, width):
Greg Ward00935822002-06-07 21:43:37 +0000191 """_handle_long_word(chunks : [string],
192 cur_line : [string],
Greg Ward62080be2002-06-10 21:37:12 +0000193 cur_len : int, width : int)
Greg Ward00935822002-06-07 21:43:37 +0000194
195 Handle a chunk of text (most likely a word, not whitespace) that
196 is too long to fit in any line.
197 """
Georg Brandlc6fde722008-01-19 19:48:19 +0000198 # Figure out when indent is larger than the specified width, and make
199 # sure at least one character is stripped off on every pass
200 if width < 1:
201 space_left = 1
202 else:
203 space_left = width - cur_len
Greg Ward00935822002-06-07 21:43:37 +0000204
205 # If we're allowed to break long words, then do so: put as much
206 # of the next chunk onto the current line as will fit.
207 if self.break_long_words:
Raymond Hettinger8bfa8932005-07-15 06:53:35 +0000208 cur_line.append(reversed_chunks[-1][:space_left])
209 reversed_chunks[-1] = reversed_chunks[-1][space_left:]
Greg Ward00935822002-06-07 21:43:37 +0000210
211 # Otherwise, we have to preserve the long word intact. Only add
212 # it to the current line if there's nothing already there --
213 # that minimizes how much we violate the width constraint.
214 elif not cur_line:
Raymond Hettinger8bfa8932005-07-15 06:53:35 +0000215 cur_line.append(reversed_chunks.pop())
Greg Ward00935822002-06-07 21:43:37 +0000216
217 # If we're not allowed to break long words, and there's already
218 # text on the current line, do nothing. Next time through the
219 # main loop of _wrap_chunks(), we'll wind up here again, but
220 # cur_len will be zero, so the next line will be entirely
221 # devoted to the long word that we can't handle right now.
222
Greg Wardd34c9592002-06-10 20:26:02 +0000223 def _wrap_chunks(self, chunks):
224 """_wrap_chunks(chunks : [string]) -> [string]
Greg Ward00935822002-06-07 21:43:37 +0000225
226 Wrap a sequence of text chunks and return a list of lines of
Greg Wardd34c9592002-06-10 20:26:02 +0000227 length 'self.width' or less. (If 'break_long_words' is false,
228 some lines may be longer than this.) Chunks correspond roughly
229 to words and the whitespace between them: each chunk is
230 indivisible (modulo 'break_long_words'), but a line break can
231 come between any two chunks. Chunks should not have internal
232 whitespace; ie. a chunk is either all whitespace or a "word".
233 Whitespace chunks will be removed from the beginning and end of
234 lines, but apart from that whitespace is preserved.
Greg Ward00935822002-06-07 21:43:37 +0000235 """
236 lines = []
Greg Ward21820cd2003-05-07 00:55:35 +0000237 if self.width <= 0:
238 raise ValueError("invalid width %r (must be > 0)" % self.width)
Greg Ward00935822002-06-07 21:43:37 +0000239
Raymond Hettinger8bfa8932005-07-15 06:53:35 +0000240 # Arrange in reverse order so items can be efficiently popped
241 # from a stack of chucks.
242 chunks.reverse()
243
Greg Ward00935822002-06-07 21:43:37 +0000244 while chunks:
245
Greg Ward62080be2002-06-10 21:37:12 +0000246 # Start the list of chunks that will make up the current line.
247 # cur_len is just the length of all the chunks in cur_line.
248 cur_line = []
249 cur_len = 0
250
251 # Figure out which static string will prefix this line.
252 if lines:
253 indent = self.subsequent_indent
254 else:
255 indent = self.initial_indent
256
257 # Maximum width for this line.
258 width = self.width - len(indent)
Greg Ward00935822002-06-07 21:43:37 +0000259
Greg Wardab73d462002-12-09 16:26:05 +0000260 # First chunk on line is whitespace -- drop it, unless this
261 # is the very beginning of the text (ie. no lines started yet).
Georg Brandl9e6b4702007-03-13 18:15:41 +0000262 if self.drop_whitespace and chunks[-1].strip() == '' and lines:
Raymond Hettinger8bfa8932005-07-15 06:53:35 +0000263 del chunks[-1]
Greg Ward00935822002-06-07 21:43:37 +0000264
265 while chunks:
Raymond Hettinger8bfa8932005-07-15 06:53:35 +0000266 l = len(chunks[-1])
Greg Ward00935822002-06-07 21:43:37 +0000267
268 # Can at least squeeze this chunk onto the current line.
269 if cur_len + l <= width:
Raymond Hettinger8bfa8932005-07-15 06:53:35 +0000270 cur_line.append(chunks.pop())
Greg Ward00935822002-06-07 21:43:37 +0000271 cur_len += l
272
273 # Nope, this line is full.
274 else:
275 break
276
277 # The current line is full, and the next chunk is too big to
Tim Petersc411dba2002-07-16 21:35:23 +0000278 # fit on *any* line (not just this one).
Raymond Hettinger8bfa8932005-07-15 06:53:35 +0000279 if chunks and len(chunks[-1]) > width:
Greg Ward62080be2002-06-10 21:37:12 +0000280 self._handle_long_word(chunks, cur_line, cur_len, width)
Greg Ward00935822002-06-07 21:43:37 +0000281
282 # If the last chunk on this line is all whitespace, drop it.
Georg Brandl9e6b4702007-03-13 18:15:41 +0000283 if self.drop_whitespace and cur_line and cur_line[-1].strip() == '':
Greg Ward00935822002-06-07 21:43:37 +0000284 del cur_line[-1]
285
286 # Convert current line back to a string and store it in list
287 # of all lines (return value).
288 if cur_line:
Greg Ward62080be2002-06-10 21:37:12 +0000289 lines.append(indent + ''.join(cur_line))
Greg Ward00935822002-06-07 21:43:37 +0000290
291 return lines
292
293
294 # -- Public interface ----------------------------------------------
295
Greg Wardd34c9592002-06-10 20:26:02 +0000296 def wrap(self, text):
297 """wrap(text : string) -> [string]
Greg Ward00935822002-06-07 21:43:37 +0000298
Greg Warde807e572002-07-04 14:51:49 +0000299 Reformat the single paragraph in 'text' so it fits in lines of
300 no more than 'self.width' columns, and return a list of wrapped
301 lines. Tabs in 'text' are expanded with string.expandtabs(),
302 and all other whitespace characters (including newline) are
303 converted to space.
Greg Ward00935822002-06-07 21:43:37 +0000304 """
305 text = self._munge_whitespace(text)
Greg Ward00935822002-06-07 21:43:37 +0000306 chunks = self._split(text)
Greg Ward62e4f3b2002-06-07 21:56:16 +0000307 if self.fix_sentence_endings:
308 self._fix_sentence_endings(chunks)
Greg Wardd34c9592002-06-10 20:26:02 +0000309 return self._wrap_chunks(chunks)
Greg Ward00935822002-06-07 21:43:37 +0000310
Greg Ward62080be2002-06-10 21:37:12 +0000311 def fill(self, text):
312 """fill(text : string) -> string
Greg Ward00935822002-06-07 21:43:37 +0000313
Greg Warde807e572002-07-04 14:51:49 +0000314 Reformat the single paragraph in 'text' to fit in lines of no
315 more than 'self.width' columns, and return a new string
316 containing the entire wrapped paragraph.
Greg Ward00935822002-06-07 21:43:37 +0000317 """
Greg Ward62080be2002-06-10 21:37:12 +0000318 return "\n".join(self.wrap(text))
Greg Ward00935822002-06-07 21:43:37 +0000319
320
Greg Warde807e572002-07-04 14:51:49 +0000321# -- Convenience interface ---------------------------------------------
Greg Ward00935822002-06-07 21:43:37 +0000322
Greg Wardcf02ac62002-06-10 20:36:07 +0000323def wrap(text, width=70, **kwargs):
Greg Warde807e572002-07-04 14:51:49 +0000324 """Wrap a single paragraph of text, returning a list of wrapped lines.
325
326 Reformat the single paragraph in 'text' so it fits in lines of no
327 more than 'width' columns, and return a list of wrapped lines. By
328 default, tabs in 'text' are expanded with string.expandtabs(), and
329 all other whitespace characters (including newline) are converted to
330 space. See TextWrapper class for available keyword args to customize
331 wrapping behaviour.
332 """
Greg Wardcf02ac62002-06-10 20:36:07 +0000333 w = TextWrapper(width=width, **kwargs)
334 return w.wrap(text)
Greg Ward00935822002-06-07 21:43:37 +0000335
Greg Ward62080be2002-06-10 21:37:12 +0000336def fill(text, width=70, **kwargs):
Greg Warde807e572002-07-04 14:51:49 +0000337 """Fill a single paragraph of text, returning a new string.
338
339 Reformat the single paragraph in 'text' to fit in lines of no more
340 than 'width' columns, and return a new string containing the entire
341 wrapped paragraph. As with wrap(), tabs are expanded and other
342 whitespace characters converted to space. See TextWrapper class for
343 available keyword args to customize wrapping behaviour.
344 """
Greg Wardcf02ac62002-06-10 20:36:07 +0000345 w = TextWrapper(width=width, **kwargs)
Greg Ward62080be2002-06-10 21:37:12 +0000346 return w.fill(text)
Greg Ward478cd482003-05-08 01:58:05 +0000347
348
349# -- Loosely related functionality -------------------------------------
350
Greg Ward7f547402006-06-11 00:40:49 +0000351_whitespace_only_re = re.compile('^[ \t]+$', re.MULTILINE)
352_leading_whitespace_re = re.compile('(^[ \t]*)(?:[^ \t\n])', re.MULTILINE)
353
Greg Ward478cd482003-05-08 01:58:05 +0000354def dedent(text):
Greg Ward7f547402006-06-11 00:40:49 +0000355 """Remove any common leading whitespace from every line in `text`.
Greg Ward478cd482003-05-08 01:58:05 +0000356
Greg Ward7f547402006-06-11 00:40:49 +0000357 This can be used to make triple-quoted strings line up with the left
358 edge of the display, while still presenting them in the source code
359 in indented form.
Greg Ward478cd482003-05-08 01:58:05 +0000360
Greg Ward7f547402006-06-11 00:40:49 +0000361 Note that tabs and spaces are both treated as whitespace, but they
362 are not equal: the lines " hello" and "\thello" are
363 considered to have no common leading whitespace. (This behaviour is
364 new in Python 2.5; older versions of this module incorrectly
365 expanded tabs before searching for common leading whitespace.)
Greg Ward478cd482003-05-08 01:58:05 +0000366 """
Greg Ward7f547402006-06-11 00:40:49 +0000367 # Look for the longest leading string of spaces and tabs common to
368 # all lines.
Greg Ward478cd482003-05-08 01:58:05 +0000369 margin = None
Greg Ward7f547402006-06-11 00:40:49 +0000370 text = _whitespace_only_re.sub('', text)
371 indents = _leading_whitespace_re.findall(text)
372 for indent in indents:
Greg Ward478cd482003-05-08 01:58:05 +0000373 if margin is None:
374 margin = indent
Greg Ward7f547402006-06-11 00:40:49 +0000375
376 # Current line more deeply indented than previous winner:
377 # no change (previous winner is still on top).
Tim Peters4f96f1f2006-06-11 19:42:51 +0000378 elif indent.startswith(margin):
379 pass
Greg Ward7f547402006-06-11 00:40:49 +0000380
381 # Current line consistent with and no deeper than previous winner:
382 # it's the new winner.
Tim Peters4f96f1f2006-06-11 19:42:51 +0000383 elif margin.startswith(indent):
384 margin = indent
Greg Ward7f547402006-06-11 00:40:49 +0000385
386 # Current line and previous winner have no common whitespace:
387 # there is no margin.
Greg Ward478cd482003-05-08 01:58:05 +0000388 else:
Greg Ward7f547402006-06-11 00:40:49 +0000389 margin = ""
390 break
Greg Ward478cd482003-05-08 01:58:05 +0000391
Greg Ward7f547402006-06-11 00:40:49 +0000392 # sanity check (testing/debugging only)
393 if 0 and margin:
394 for line in text.split("\n"):
395 assert not line or line.startswith(margin), \
396 "line = %r, margin = %r" % (line, margin)
Greg Ward478cd482003-05-08 01:58:05 +0000397
Greg Ward7f547402006-06-11 00:40:49 +0000398 if margin:
399 text = re.sub(r'(?m)^' + margin, '', text)
400 return text
401
402if __name__ == "__main__":
403 #print dedent("\tfoo\n\tbar")
404 #print dedent(" \thello there\n \t how are you?")
405 print dedent("Hello there.\n This is indented.")