# HG changeset patch # User Atul Varma # Date 1212784600 25200 # Node ID 1b6fc390ffc712fe29379103422f87a9a7561953 # Parent af7d50fc8cfd6080f8e365d4186b2328db9cf5cf Normalized whitespace on doctests. diff -r af7d50fc8cfd -r 1b6fc390ffc7 Makefile --- a/Makefile Fri Jun 06 13:20:37 2008 -0700 +++ b/Makefile Fri Jun 06 13:36:40 2008 -0700 @@ -2,4 +2,4 @@ rst2html.py --stylesheet-path=PythonForJsProgrammers.css --link-stylesheet PythonForJsProgrammers.txt > PythonForJsProgrammers.html test: - python -c "import doctest; doctest.testfile('PythonForJsProgrammers.txt')" + python -c "import doctest; doctest.testfile('PythonForJsProgrammers.txt', optionflags=doctest.NORMALIZE_WHITESPACE)" diff -r af7d50fc8cfd -r 1b6fc390ffc7 PythonForJsProgrammers.html --- a/PythonForJsProgrammers.html Fri Jun 06 13:20:37 2008 -0700 +++ b/PythonForJsProgrammers.html Fri Jun 06 13:36:40 2008 -0700 @@ -104,7 +104,18 @@
 >>> dir("a string")
-['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__str__', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']
+['__add__', '__class__', '__contains__', '__delattr__', '__doc__',
+ '__eq__', '__ge__', '__getattribute__', '__getitem__',
+ '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__',
+ '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__',
+ '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__',
+ '__rmul__', '__setattr__', '__str__', 'capitalize', 'center',
+ 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find',
+ 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace',
+ 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip',
+ 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition',
+ 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip',
+ 'swapcase', 'title', 'translate', 'upper', 'zfill']
 

If there's a function you're interested in learning more about, you @@ -767,7 +778,8 @@ >>> u"hello\u2026".encode("ascii") Traceback (most recent call last): ... -UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 5: ordinal not in range(128) +UnicodeEncodeError: 'ascii' codec can't encode character +u'\u2026' in position 5: ordinal not in range(128)

As such, it's a good idea to optionally specify an algorithm to deal diff -r af7d50fc8cfd -r 1b6fc390ffc7 PythonForJsProgrammers.txt --- a/PythonForJsProgrammers.txt Fri Jun 06 13:20:37 2008 -0700 +++ b/PythonForJsProgrammers.txt Fri Jun 06 13:36:40 2008 -0700 @@ -106,7 +106,18 @@ attributes attached to an object: >>> dir("a string") - ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', '__eq__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', '__rmul__', '__setattr__', '__str__', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill'] + ['__add__', '__class__', '__contains__', '__delattr__', '__doc__', + '__eq__', '__ge__', '__getattribute__', '__getitem__', + '__getnewargs__', '__getslice__', '__gt__', '__hash__', '__init__', + '__le__', '__len__', '__lt__', '__mod__', '__mul__', '__ne__', + '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmod__', + '__rmul__', '__setattr__', '__str__', 'capitalize', 'center', + 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', + 'index', 'isalnum', 'isalpha', 'isdigit', 'islower', 'isspace', + 'istitle', 'isupper', 'join', 'ljust', 'lower', 'lstrip', + 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', + 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', + 'swapcase', 'title', 'translate', 'upper', 'zfill'] If there's a function you're interested in learning more about, you can look at the built-in documentation metadata associated with the @@ -711,7 +722,8 @@ >>> u"hello\u2026".encode("ascii") Traceback (most recent call last): ... - UnicodeEncodeError: 'ascii' codec can't encode character u'\u2026' in position 5: ordinal not in range(128) + UnicodeEncodeError: 'ascii' codec can't encode character + u'\u2026' in position 5: ordinal not in range(128) As such, it's a good idea to optionally specify an algorithm to deal with characters that aren't supported by the encoding: