Add the 'bool' type and its values 'False' and 'True', as described in

PEP 285.  Everything described in the PEP is here, and there is even
some documentation.  I had to fix 12 unit tests; all but one of these
were printing Boolean outcomes that changed from 0/1 to False/True.
(The exception is test_unicode.py, which did a type(x) == type(y)
style comparison.  I could've fixed that with a single line using
issubtype(x, type(y)), but instead chose to be explicit about those
places where a bool is expected.

Still to do: perhaps more documentation; change standard library
modules to return False/True from predicates.
This commit is contained in:
Guido van Rossum 2002-04-03 22:41:51 +00:00
parent e9c0358bf4
commit 77f6a65eb0
29 changed files with 489 additions and 378 deletions

View file

@ -976,11 +976,11 @@ def IS_LINE_JUNK(line, pat=re.compile(r"\s*#?\s*$").match):
Examples:
>>> IS_LINE_JUNK('\n')
1
True
>>> IS_LINE_JUNK(' # \n')
1
True
>>> IS_LINE_JUNK('hello\n')
0
False
"""
return pat(line) is not None
@ -992,13 +992,13 @@ def IS_CHARACTER_JUNK(ch, ws=" \t"):
Examples:
>>> IS_CHARACTER_JUNK(' ')
1
True
>>> IS_CHARACTER_JUNK('\t')
1
True
>>> IS_CHARACTER_JUNK('\n')
0
False
>>> IS_CHARACTER_JUNK('x')
0
False
"""
return ch in ws

View file

@ -545,19 +545,19 @@ def is_private(prefix, base):
does not both begin and end with (at least) two underscores.
>>> is_private("a.b", "my_func")
0
False
>>> is_private("____", "_my_func")
1
True
>>> is_private("someclass", "__init__")
0
False
>>> is_private("sometypo", "__init_")
1
True
>>> is_private("x.y.z", "_")
1
True
>>> is_private("_x.y.z", "__")
0
False
>>> is_private("", "") # senseless but consistent
0
False
"""
return base[:1] == "_" and not base[:2] == "__" == base[-2:]

View file

@ -101,6 +101,9 @@ TUPLE = 't'
EMPTY_TUPLE = ')'
SETITEMS = 'u'
BINFLOAT = 'G'
TRUE = 'Z'
FALSE = 'z'
__all__.extend([x for x in dir() if re.match("[A-Z][A-Z0-9_]+$",x)])
del x
@ -256,6 +259,13 @@ class Pickler:
self.write(NONE)
dispatch[NoneType] = save_none
def save_bool(self, object):
if object:
self.write(TRUE)
else:
self.write(FALSE)
dispatch[bool] = save_bool
def save_int(self, object):
if self.bin:
# If the int is small enough to fit in a signed 4-byte 2's-comp
@ -629,6 +639,14 @@ class Unpickler:
self.append(None)
dispatch[NONE] = load_none
def load_false(self):
self.append(False)
dispatch[FALSE] = load_false
def load_true(self):
self.append(True)
dispatch[TRUE] = load_true
def load_int(self):
data = self.readline()
try:

View file

@ -4,14 +4,14 @@ test_augassign
6
[1, 2, 3, 4, 1, 2, 3, 4]
[1, 2, 1, 2, 3]
1
1
1
True
True
True
11
1
True
12
1
1
True
True
13
__add__ called
__radd__ called

View file

@ -31,7 +31,7 @@ h() argument after ** must be a dictionary
dir() argument after ** must be a dictionary
NoneType object argument after ** must be a dictionary
dir() got multiple values for keyword argument 'b'
3 512 1
3 512 True
3
3
za () {} -> za() takes exactly 1 argument (0 given)

View file

@ -23,7 +23,7 @@ trggrkg zrffntr pngnybt yvoenel.
wink wink
bacon
test api 2
1
True
gettext
albatross
bacon

View file

@ -60,6 +60,6 @@ classdef
[3, 4, 5]
[(1, 'Apple'), (1, 'Banana'), (1, 'Coconut'), (2, 'Apple'), (2, 'Banana'), (2, 'Coconut'), (3, 'Apple'), (3, 'Banana'), (3, 'Coconut'), (4, 'Apple'), (4, 'Banana'), (4, 'Coconut'), (5, 'Apple'), (5, 'Banana'), (5, 'Coconut')]
[(1, 'Banana'), (1, 'Coconut'), (2, 'Banana'), (2, 'Coconut'), (3, 'Banana'), (3, 'Coconut'), (4, 'Banana'), (4, 'Coconut'), (5, 'Banana'), (5, 'Coconut')]
[0, 0, 0]
[False, False, False]
[[1, 2], [3, 4], [5, 6]]
[('Boeing', 'Airliner'), ('Boeing', 'Engine'), ('Ford', 'Engine'), ('Macdonalds', 'Cheeseburger')]

View file

@ -4,54 +4,54 @@ operator: <
| Number(0) | Number(1) | Number(2) |
----------+-----------+-----------+-----------+-
Number(0) | 0 | 1 | 1 |
Number(1) | 0 | 0 | 1 |
Number(2) | 0 | 0 | 0 |
Number(0) | False | True | True |
Number(1) | False | False | True |
Number(2) | False | False | False |
----------+-----------+-----------+-----------+-
operator: <=
| Number(0) | Number(1) | Number(2) |
----------+-----------+-----------+-----------+-
Number(0) | 1 | 1 | 1 |
Number(1) | 0 | 1 | 1 |
Number(2) | 0 | 0 | 1 |
Number(0) | True | True | True |
Number(1) | False | True | True |
Number(2) | False | False | True |
----------+-----------+-----------+-----------+-
operator: ==
| Number(0) | Number(1) | Number(2) |
----------+-----------+-----------+-----------+-
Number(0) | 1 | 0 | 0 |
Number(1) | 0 | 1 | 0 |
Number(2) | 0 | 0 | 1 |
Number(0) | True | False | False |
Number(1) | False | True | False |
Number(2) | False | False | True |
----------+-----------+-----------+-----------+-
operator: !=
| Number(0) | Number(1) | Number(2) |
----------+-----------+-----------+-----------+-
Number(0) | 0 | 1 | 1 |
Number(1) | 1 | 0 | 1 |
Number(2) | 1 | 1 | 0 |
Number(0) | False | True | True |
Number(1) | True | False | True |
Number(2) | True | True | False |
----------+-----------+-----------+-----------+-
operator: >
| Number(0) | Number(1) | Number(2) |
----------+-----------+-----------+-----------+-
Number(0) | 0 | 0 | 0 |
Number(1) | 1 | 0 | 0 |
Number(2) | 1 | 1 | 0 |
Number(0) | False | False | False |
Number(1) | True | False | False |
Number(2) | True | True | False |
----------+-----------+-----------+-----------+-
operator: >=
| Number(0) | Number(1) | Number(2) |
----------+-----------+-----------+-----------+-
Number(0) | 1 | 0 | 0 |
Number(1) | 1 | 1 | 0 |
Number(2) | 1 | 1 | 1 |
Number(0) | True | False | False |
Number(1) | True | True | False |
Number(2) | True | True | True |
----------+-----------+-----------+-----------+-
**************************************************
@ -60,54 +60,54 @@ operator: <
| Number(0) | Number(1) | Number(2) |
----------+-----------+-----------+-----------+-
0 | 0 | 1 | 1 |
1 | 0 | 0 | 1 |
2 | 0 | 0 | 0 |
0 | False | True | True |
1 | False | False | True |
2 | False | False | False |
----------+-----------+-----------+-----------+-
operator: <=
| Number(0) | Number(1) | Number(2) |
----------+-----------+-----------+-----------+-
0 | 1 | 1 | 1 |
1 | 0 | 1 | 1 |
2 | 0 | 0 | 1 |
0 | True | True | True |
1 | False | True | True |
2 | False | False | True |
----------+-----------+-----------+-----------+-
operator: ==
| Number(0) | Number(1) | Number(2) |
----------+-----------+-----------+-----------+-
0 | 1 | 0 | 0 |
1 | 0 | 1 | 0 |
2 | 0 | 0 | 1 |
0 | True | False | False |
1 | False | True | False |
2 | False | False | True |
----------+-----------+-----------+-----------+-
operator: !=
| Number(0) | Number(1) | Number(2) |
----------+-----------+-----------+-----------+-
0 | 0 | 1 | 1 |
1 | 1 | 0 | 1 |
2 | 1 | 1 | 0 |
0 | False | True | True |
1 | True | False | True |
2 | True | True | False |
----------+-----------+-----------+-----------+-
operator: >
| Number(0) | Number(1) | Number(2) |
----------+-----------+-----------+-----------+-
0 | 0 | 0 | 0 |
1 | 1 | 0 | 0 |
2 | 1 | 1 | 0 |
0 | False | False | False |
1 | True | False | False |
2 | True | True | False |
----------+-----------+-----------+-----------+-
operator: >=
| Number(0) | Number(1) | Number(2) |
----------+-----------+-----------+-----------+-
0 | 1 | 0 | 0 |
1 | 1 | 1 | 0 |
2 | 1 | 1 | 1 |
0 | True | False | False |
1 | True | True | False |
2 | True | True | True |
----------+-----------+-----------+-----------+-
**************************************************
@ -116,72 +116,72 @@ operator: <
| 0 | 1 | 2 |
----------+-----------+-----------+-----------+-
Number(0) | 0 | 1 | 1 |
Number(1) | 0 | 0 | 1 |
Number(2) | 0 | 0 | 0 |
Number(0) | False | True | True |
Number(1) | False | False | True |
Number(2) | False | False | False |
----------+-----------+-----------+-----------+-
operator: <=
| 0 | 1 | 2 |
----------+-----------+-----------+-----------+-
Number(0) | 1 | 1 | 1 |
Number(1) | 0 | 1 | 1 |
Number(2) | 0 | 0 | 1 |
Number(0) | True | True | True |
Number(1) | False | True | True |
Number(2) | False | False | True |
----------+-----------+-----------+-----------+-
operator: ==
| 0 | 1 | 2 |
----------+-----------+-----------+-----------+-
Number(0) | 1 | 0 | 0 |
Number(1) | 0 | 1 | 0 |
Number(2) | 0 | 0 | 1 |
Number(0) | True | False | False |
Number(1) | False | True | False |
Number(2) | False | False | True |
----------+-----------+-----------+-----------+-
operator: !=
| 0 | 1 | 2 |
----------+-----------+-----------+-----------+-
Number(0) | 0 | 1 | 1 |
Number(1) | 1 | 0 | 1 |
Number(2) | 1 | 1 | 0 |
Number(0) | False | True | True |
Number(1) | True | False | True |
Number(2) | True | True | False |
----------+-----------+-----------+-----------+-
operator: >
| 0 | 1 | 2 |
----------+-----------+-----------+-----------+-
Number(0) | 0 | 0 | 0 |
Number(1) | 1 | 0 | 0 |
Number(2) | 1 | 1 | 0 |
Number(0) | False | False | False |
Number(1) | True | False | False |
Number(2) | True | True | False |
----------+-----------+-----------+-----------+-
operator: >=
| 0 | 1 | 2 |
----------+-----------+-----------+-----------+-
Number(0) | 1 | 0 | 0 |
Number(1) | 1 | 1 | 0 |
Number(2) | 1 | 1 | 1 |
Number(0) | True | False | False |
Number(1) | True | True | False |
Number(2) | True | True | True |
----------+-----------+-----------+-----------+-
**************************************************
Vector([0, 1, 2, 3, 4]) < Vector([2, 2, 2, 2, 2]) -> Vector([1, 1, 0, 0, 0])
Vector([0, 1, 2, 3, 4]) < [2, 2, 2, 2, 2] -> Vector([1, 1, 0, 0, 0])
[0, 1, 2, 3, 4] < Vector([2, 2, 2, 2, 2]) -> Vector([1, 1, 0, 0, 0])
Vector([0, 1, 2, 3, 4]) <= Vector([2, 2, 2, 2, 2]) -> Vector([1, 1, 1, 0, 0])
Vector([0, 1, 2, 3, 4]) <= [2, 2, 2, 2, 2] -> Vector([1, 1, 1, 0, 0])
[0, 1, 2, 3, 4] <= Vector([2, 2, 2, 2, 2]) -> Vector([1, 1, 1, 0, 0])
Vector([0, 1, 2, 3, 4]) == Vector([2, 2, 2, 2, 2]) -> Vector([0, 0, 1, 0, 0])
Vector([0, 1, 2, 3, 4]) == [2, 2, 2, 2, 2] -> Vector([0, 0, 1, 0, 0])
[0, 1, 2, 3, 4] == Vector([2, 2, 2, 2, 2]) -> Vector([0, 0, 1, 0, 0])
Vector([0, 1, 2, 3, 4]) != Vector([2, 2, 2, 2, 2]) -> Vector([1, 1, 0, 1, 1])
Vector([0, 1, 2, 3, 4]) != [2, 2, 2, 2, 2] -> Vector([1, 1, 0, 1, 1])
[0, 1, 2, 3, 4] != Vector([2, 2, 2, 2, 2]) -> Vector([1, 1, 0, 1, 1])
Vector([0, 1, 2, 3, 4]) > Vector([2, 2, 2, 2, 2]) -> Vector([0, 0, 0, 1, 1])
Vector([0, 1, 2, 3, 4]) > [2, 2, 2, 2, 2] -> Vector([0, 0, 0, 1, 1])
[0, 1, 2, 3, 4] > Vector([2, 2, 2, 2, 2]) -> Vector([0, 0, 0, 1, 1])
Vector([0, 1, 2, 3, 4]) >= Vector([2, 2, 2, 2, 2]) -> Vector([0, 0, 1, 1, 1])
Vector([0, 1, 2, 3, 4]) >= [2, 2, 2, 2, 2] -> Vector([0, 0, 1, 1, 1])
[0, 1, 2, 3, 4] >= Vector([2, 2, 2, 2, 2]) -> Vector([0, 0, 1, 1, 1])
Vector([0, 1, 2, 3, 4]) < Vector([2, 2, 2, 2, 2]) -> Vector([True, True, False, False, False])
Vector([0, 1, 2, 3, 4]) < [2, 2, 2, 2, 2] -> Vector([True, True, False, False, False])
[0, 1, 2, 3, 4] < Vector([2, 2, 2, 2, 2]) -> Vector([True, True, False, False, False])
Vector([0, 1, 2, 3, 4]) <= Vector([2, 2, 2, 2, 2]) -> Vector([True, True, True, False, False])
Vector([0, 1, 2, 3, 4]) <= [2, 2, 2, 2, 2] -> Vector([True, True, True, False, False])
[0, 1, 2, 3, 4] <= Vector([2, 2, 2, 2, 2]) -> Vector([True, True, True, False, False])
Vector([0, 1, 2, 3, 4]) == Vector([2, 2, 2, 2, 2]) -> Vector([False, False, True, False, False])
Vector([0, 1, 2, 3, 4]) == [2, 2, 2, 2, 2] -> Vector([False, False, True, False, False])
[0, 1, 2, 3, 4] == Vector([2, 2, 2, 2, 2]) -> Vector([False, False, True, False, False])
Vector([0, 1, 2, 3, 4]) != Vector([2, 2, 2, 2, 2]) -> Vector([True, True, False, True, True])
Vector([0, 1, 2, 3, 4]) != [2, 2, 2, 2, 2] -> Vector([True, True, False, True, True])
[0, 1, 2, 3, 4] != Vector([2, 2, 2, 2, 2]) -> Vector([True, True, False, True, True])
Vector([0, 1, 2, 3, 4]) > Vector([2, 2, 2, 2, 2]) -> Vector([False, False, False, True, True])
Vector([0, 1, 2, 3, 4]) > [2, 2, 2, 2, 2] -> Vector([False, False, False, True, True])
[0, 1, 2, 3, 4] > Vector([2, 2, 2, 2, 2]) -> Vector([False, False, False, True, True])
Vector([0, 1, 2, 3, 4]) >= Vector([2, 2, 2, 2, 2]) -> Vector([False, False, True, True, True])
Vector([0, 1, 2, 3, 4]) >= [2, 2, 2, 2, 2] -> Vector([False, False, True, True, True])
[0, 1, 2, 3, 4] >= Vector([2, 2, 2, 2, 2]) -> Vector([False, False, True, True, True])

View file

@ -2329,7 +2329,7 @@ def descrdoc():
if verbose: print "Testing descriptor doc strings..."
def check(descr, what):
vereq(descr.__doc__, what)
check(file.closed, "flag set if the file is closed") # getset descriptor
check(file.closed, "True if the file is closed") # getset descriptor
check(file.name, "file name") # member descriptor
def setclass():

View file

@ -48,7 +48,7 @@ Here's the new type at work:
>>> print a.__class__ # show its class
<class 'test.test_descrtut.defaultdict'>
>>> print type(a) is a.__class__ # its type is its class
1
True
>>> a[1] = 3.25 # modify the instance
>>> print a # show the new value
{1: 3.25}
@ -98,14 +98,14 @@ just like classic classes:
>>> print a["noway"]
-1000
>>> 'default' in dir(a)
1
True
>>> a.x1 = 100
>>> a.x2 = 200
>>> print a.x1
100
>>> d = dir(a)
>>> 'default' in d and 'x1' in d and 'x2' in d
1
True
>>> print a.__dict__
{'default': -1000, 'x2': 200, 'x1': 100}
>>>
@ -167,11 +167,11 @@ For instance of built-in types, x.__class__ is now the same as type(x):
>>> list
<type 'list'>
>>> isinstance([], list)
1
True
>>> isinstance([], dict)
0
False
>>> isinstance([], object)
1
True
>>>
Under the new proposal, the __methods__ attribute no longer exists:

View file

@ -386,10 +386,10 @@ From the Iterators list, about the types of these things.
>>> print i.next.__doc__
x.next() -> the next value, or raise StopIteration
>>> iter(i) is i
1
True
>>> import types
>>> isinstance(i, types.GeneratorType)
1
True
And more, added later.
@ -1218,16 +1218,16 @@ generated sequence, you need to copy its results.
>>> for n in range(10):
... all = list(gencopy(conjoin([lambda: iter((0, 1))] * n)))
... print n, len(all), all[0] == [0] * n, all[-1] == [1] * n
0 1 1 1
1 2 1 1
2 4 1 1
3 8 1 1
4 16 1 1
5 32 1 1
6 64 1 1
7 128 1 1
8 256 1 1
9 512 1 1
0 1 True True
1 2 True True
2 4 True True
3 8 True True
4 16 True True
5 32 True True
6 64 True True
7 128 True True
8 256 True True
9 512 True True
And run an 8-queens solver.

View file

@ -167,34 +167,34 @@ test('replace', u'one!two!three!', u'one@two@three@', u'!', u'@')
test('replace', u'one!two!three!', u'one!two!three!', u'x', u'@')
test('replace', u'one!two!three!', u'one!two!three!', u'x', u'@', 2)
test('startswith', u'hello', 1, u'he')
test('startswith', u'hello', 1, u'hello')
test('startswith', u'hello', 0, u'hello world')
test('startswith', u'hello', 1, u'')
test('startswith', u'hello', 0, u'ello')
test('startswith', u'hello', 1, u'ello', 1)
test('startswith', u'hello', 1, u'o', 4)
test('startswith', u'hello', 0, u'o', 5)
test('startswith', u'hello', 1, u'', 5)
test('startswith', u'hello', 0, u'lo', 6)
test('startswith', u'helloworld', 1, u'lowo', 3)
test('startswith', u'helloworld', 1, u'lowo', 3, 7)
test('startswith', u'helloworld', 0, u'lowo', 3, 6)
test('startswith', u'hello', True, u'he')
test('startswith', u'hello', True, u'hello')
test('startswith', u'hello', False, u'hello world')
test('startswith', u'hello', True, u'')
test('startswith', u'hello', False, u'ello')
test('startswith', u'hello', True, u'ello', 1)
test('startswith', u'hello', True, u'o', 4)
test('startswith', u'hello', False, u'o', 5)
test('startswith', u'hello', True, u'', 5)
test('startswith', u'hello', False, u'lo', 6)
test('startswith', u'helloworld', True, u'lowo', 3)
test('startswith', u'helloworld', True, u'lowo', 3, 7)
test('startswith', u'helloworld', False, u'lowo', 3, 6)
test('endswith', u'hello', 1, u'lo')
test('endswith', u'hello', 0, u'he')
test('endswith', u'hello', 1, u'')
test('endswith', u'hello', 0, u'hello world')
test('endswith', u'helloworld', 0, u'worl')
test('endswith', u'helloworld', 1, u'worl', 3, 9)
test('endswith', u'helloworld', 1, u'world', 3, 12)
test('endswith', u'helloworld', 1, u'lowo', 1, 7)
test('endswith', u'helloworld', 1, u'lowo', 2, 7)
test('endswith', u'helloworld', 1, u'lowo', 3, 7)
test('endswith', u'helloworld', 0, u'lowo', 4, 7)
test('endswith', u'helloworld', 0, u'lowo', 3, 8)
test('endswith', u'ab', 0, u'ab', 0, 1)
test('endswith', u'ab', 0, u'ab', 0, 0)
test('endswith', u'hello', True, u'lo')
test('endswith', u'hello', False, u'he')
test('endswith', u'hello', True, u'')
test('endswith', u'hello', False, u'hello world')
test('endswith', u'helloworld', False, u'worl')
test('endswith', u'helloworld', True, u'worl', 3, 9)
test('endswith', u'helloworld', True, u'world', 3, 12)
test('endswith', u'helloworld', True, u'lowo', 1, 7)
test('endswith', u'helloworld', True, u'lowo', 2, 7)
test('endswith', u'helloworld', True, u'lowo', 3, 7)
test('endswith', u'helloworld', False, u'lowo', 4, 7)
test('endswith', u'helloworld', False, u'lowo', 3, 8)
test('endswith', u'ab', False, u'ab', 0, 1)
test('endswith', u'ab', False, u'ab', 0, 0)
test('expandtabs', u'abc\rab\tdef\ng\thi', u'abc\rab def\ng hi')
test('expandtabs', u'abc\rab\tdef\ng\thi', u'abc\rab def\ng hi', 8)
@ -286,50 +286,50 @@ test('ljust', u'abc', u'abc', 2)
test('rjust', u'abc', u'abc', 2)
test('center', u'abc', u'abc', 2)
test('islower', u'a', 1)
test('islower', u'A', 0)
test('islower', u'\n', 0)
test('islower', u'\u1FFc', 0)
test('islower', u'abc', 1)
test('islower', u'aBc', 0)
test('islower', u'abc\n', 1)
test('islower', u'a', True)
test('islower', u'A', False)
test('islower', u'\n', False)
test('islower', u'\u1FFc', False)
test('islower', u'abc', True)
test('islower', u'aBc', False)
test('islower', u'abc\n', True)
test('isupper', u'a', 0)
test('isupper', u'A', 1)
test('isupper', u'\n', 0)
test('isupper', u'a', False)
test('isupper', u'A', True)
test('isupper', u'\n', False)
if sys.platform[:4] != 'java':
test('isupper', u'\u1FFc', 0)
test('isupper', u'ABC', 1)
test('isupper', u'AbC', 0)
test('isupper', u'ABC\n', 1)
test('isupper', u'\u1FFc', False)
test('isupper', u'ABC', True)
test('isupper', u'AbC', False)
test('isupper', u'ABC\n', True)
test('istitle', u'a', 0)
test('istitle', u'A', 1)
test('istitle', u'\n', 0)
test('istitle', u'\u1FFc', 1)
test('istitle', u'A Titlecased Line', 1)
test('istitle', u'A\nTitlecased Line', 1)
test('istitle', u'A Titlecased, Line', 1)
test('istitle', u'Greek \u1FFcitlecases ...', 1)
test('istitle', u'Not a capitalized String', 0)
test('istitle', u'Not\ta Titlecase String', 0)
test('istitle', u'Not--a Titlecase String', 0)
test('istitle', u'a', False)
test('istitle', u'A', True)
test('istitle', u'\n', False)
test('istitle', u'\u1FFc', True)
test('istitle', u'A Titlecased Line', True)
test('istitle', u'A\nTitlecased Line', True)
test('istitle', u'A Titlecased, Line', True)
test('istitle', u'Greek \u1FFcitlecases ...', True)
test('istitle', u'Not a capitalized String', False)
test('istitle', u'Not\ta Titlecase String', False)
test('istitle', u'Not--a Titlecase String', False)
test('isalpha', u'a', 1)
test('isalpha', u'A', 1)
test('isalpha', u'\n', 0)
test('isalpha', u'\u1FFc', 1)
test('isalpha', u'abc', 1)
test('isalpha', u'aBc123', 0)
test('isalpha', u'abc\n', 0)
test('isalpha', u'a', True)
test('isalpha', u'A', True)
test('isalpha', u'\n', False)
test('isalpha', u'\u1FFc', True)
test('isalpha', u'abc', True)
test('isalpha', u'aBc123', False)
test('isalpha', u'abc\n', False)
test('isalnum', u'a', 1)
test('isalnum', u'A', 1)
test('isalnum', u'\n', 0)
test('isalnum', u'123abc456', 1)
test('isalnum', u'a1b3c', 1)
test('isalnum', u'aBc000 ', 0)
test('isalnum', u'abc\n', 0)
test('isalnum', u'a', True)
test('isalnum', u'A', True)
test('isalnum', u'\n', False)
test('isalnum', u'123abc456', True)
test('isalnum', u'a1b3c', True)
test('isalnum', u'aBc000 ', False)
test('isalnum', u'abc\n', False)
test('splitlines', u"abc\ndef\n\rghi", [u'abc', u'def', u'', u'ghi'])
test('splitlines', u"abc\ndef\n\r\nghi", [u'abc', u'def', u'', u'ghi'])
@ -337,7 +337,7 @@ test('splitlines', u"abc\ndef\r\nghi", [u'abc', u'def', u'ghi'])
test('splitlines', u"abc\ndef\r\nghi\n", [u'abc', u'def', u'ghi'])
test('splitlines', u"abc\ndef\r\nghi\n\r", [u'abc', u'def', u'ghi', u''])
test('splitlines', u"\nabc\ndef\r\nghi\n\r", [u'', u'abc', u'def', u'ghi', u''])
test('splitlines', u"\nabc\ndef\r\nghi\n\r", [u'\n', u'abc\n', u'def\r\n', u'ghi\n', u'\r'], 1)
test('splitlines', u"\nabc\ndef\r\nghi\n\r", [u'\n', u'abc\n', u'def\r\n', u'ghi\n', u'\r'], True)
test('translate', u"abababc", u'bbbc', {ord('a'):None})
test('translate', u"abababc", u'iiic', {ord('a'):None, ord('b'):ord('i')})