Hi,

Since Python 3000 regular expressions are now Unicode by default, how can I 
use bytes regex? Very simplified example of my problem:
  import re
  print( re.sub("(.)", b"[\\1]", b'abc') )

This code fails with exception:
  File "(...)/py3k-struni/Lib/re.py", line 241, in _compile_repl
     p = _cache_repl.get(key)
  TypeError: unhashable type: 'bytes'

Does "frozen bytes type" (immutable) exist to be able to use a cache?

Victor Stinner aka haypo
http://hachoir.org/
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to