textwrap.fill algorithm? (Difference with vim)
mcepl at cepl.eu
Fri Apr 21 17:26:20 EDT 2017
I have a gedit Python plugin which should do line wrap using
textwrap.fill() function. However, even when I have set the
length of line to the same number as in vim (65), the result is
substantially different (textwrap.fill paragraphs are
significantly narrower). See for example this diff (removed
lines are wrapped by vim, added by textwrap.fill-based plugin).
Why cannot textwrap.fill get those words “grown so” to the first
line of the wrapped text? Any ideas about the difference in the
algorithms for line-wrapping in vim and in textwrapper.fill?
Thank you for any suggestions,
~$ git diff -- mind.rst
diff --git a/mind.rst b/mind.rst
index a9523c2..e55c56b 100644
@@ -63,16 +63,18 @@ personal religious belief. It is a commentary, in the light of
specialised knowledge, on a particular set of statements made in the
Christian creeds and their claim to be statements of fact.
-It is necessary to issue this caution, for the popular mind has grown so
-confused that it is no longer able to receive any statement of fact
-except as an expression of personal feeling. Some time ago, the present
-writer, pardonably irritated by a very prevalent ignorance concerning
-the essentials of Christian doctrine, published a brief article in which
-those essentials were plainly set down in words that a child could
-understand. Every clause was preceded by some such phrase as: “the
-Church maintains”, “the Church teaches”, “if the Church is right”, and
-so forth. The only personal opinion expressed was that, though the
-doctrine might be false, it could not very well be called dull.
+It is necessary to issue this caution, for the popular mind has
+grown so confused that it is no longer able to receive any
+statement of fact except as an expression of personal feeling.
+Some time ago, the present writer, pardonably irritated by a very
+prevalent ignorance concerning the essentials of Christian
+doctrine, published a brief article in which those essentials
+were plainly set down in words that a child could understand.
+Every clause was preceded by some such phrase as: “the Church
+maintains”, “the Church teaches”, “if the Church is
+right”, and so forth. The only personal opinion expressed was
+that, though the doctrine might be false, it could not very well
+be called dull.
Every newspaper that reviewed this article accepted it without question
as a profession of faith-some (Heaven knows why) called it “a courageous
More information about the Python-list