]> granicus.if.org Git - python/commitdiff
Minor clarification of dedent().
authorGreg Ward <gward@python.net>
Thu, 8 May 2003 02:02:50 +0000 (02:02 +0000)
committerGreg Ward <gward@python.net>
Thu, 8 May 2003 02:02:50 +0000 (02:02 +0000)
Lib/textwrap.py

index ec0e7cbe0160d756948a72116ff6e317540ee87f..754b037323ea78ef5efd32a6b594dce841dd9fd6 100644 (file)
@@ -334,16 +334,16 @@ def dedent(text):
     lines = text.expandtabs().split('\n')
     margin = None
     for line in lines:
-        content = len(line.lstrip())
+        content = line.lstrip()
         if not content:
             continue
-        indent = len(line) - content
+        indent = len(line) - len(content)
         if margin is None:
             margin = indent
         else:
             margin = min(margin, indent)
 
-    if margin is not None:
+    if margin is not None and margin > 0:
         for i in range(len(lines)):
             lines[i] = lines[i][margin:]