diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2004-03-25 13:50:59 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2004-03-25 13:50:59 (GMT) |
commit | bc503d1e90fac2baf8f3f115692c9ac940e9d5bb (patch) | |
tree | 085b0948f0c1ba4281b1358330a61b0179ab4f46 /Lib/sre_compile.py | |
parent | 5232f50b19b727a8a6aa445919bffe7a6bbb2e5c (diff) | |
download | cpython-bc503d1e90fac2baf8f3f115692c9ac940e9d5bb.zip cpython-bc503d1e90fac2baf8f3f115692c9ac940e9d5bb.tar.gz cpython-bc503d1e90fac2baf8f3f115692c9ac940e9d5bb.tar.bz2 |
Use True/False instead of 0/1 for character classes.
Diffstat (limited to 'Lib/sre_compile.py')
-rw-r--r-- | Lib/sre_compile.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py index ee0882d..1d5dae3 100644 --- a/Lib/sre_compile.py +++ b/Lib/sre_compile.py @@ -193,16 +193,16 @@ def _compile_charset(charset, flags, code, fixup=None): def _optimize_charset(charset, fixup): # internal: optimize character set out = [] - charmap = [0]*256 + charmap = [False]*256 try: for op, av in charset: if op is NEGATE: out.append((op, av)) elif op is LITERAL: - charmap[fixup(av)] = 1 + charmap[fixup(av)] = True elif op is RANGE: for i in range(fixup(av[0]), fixup(av[1])+1): - charmap[i] = 1 + charmap[i] = True elif op is CATEGORY: # XXX: could append to charmap tail return charset # cannot compress @@ -286,17 +286,17 @@ def _optimize_unicode(charset, fixup): import array except ImportError: return charset - charmap = [0]*65536 + charmap = [False]*65536 negate = 0 try: for op, av in charset: if op is NEGATE: negate = 1 elif op is LITERAL: - charmap[fixup(av)] = 1 + charmap[fixup(av)] = True elif op is RANGE: for i in range(fixup(av[0]), fixup(av[1])+1): - charmap[i] = 1 + charmap[i] = True elif op is CATEGORY: # XXX: could expand category return charset # cannot compress |