diff options
Diffstat (limited to 'examples/removeLineBreaks.py')
-rw-r--r-- | examples/removeLineBreaks.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/removeLineBreaks.py b/examples/removeLineBreaks.py index 1a77231..03315be 100644 --- a/examples/removeLineBreaks.py +++ b/examples/removeLineBreaks.py @@ -18,11 +18,14 @@ line_end = pp.LineEnd() # define an expression for the body of a line of text - use a predicate condition to # accept only lines with some content. def mustBeNonBlank(t): - return t[0] != '' + return t[0] != "" # could also be written as # return bool(t[0]) -lineBody = pp.SkipTo(line_end).addCondition(mustBeNonBlank, message="line body can't be empty") + +lineBody = pp.SkipTo(line_end).addCondition( + mustBeNonBlank, message="line body can't be empty" +) # now define a line with a trailing lineEnd, to be replaced with a space character textLine = lineBody + line_end().setParseAction(pp.replaceWith(" ")) |