[Tutor] Re: problems with re module

Thomi Richards thomi at imail.net.nz
Sat Nov 15 16:50:25 EST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>
> Once the task becomes more complex, I usually end up using groups
> and moving the substitution out in to a separate function:
>

hmm.. your test app worked great, but when i try to use your functions in my 
code, I get the following error:

Traceback (most recent call last):
  File "./scripts/conv.py", line 119, in ?
    writeln('<entry>%s</entry>' % (procol(col)) )
  File "./scripts/conv.py", line 42, in procol
    msg = re.sub(r"<(Graphics\s+file:\s+)([^>]*)>", f, message)
  File "/usr/lib/python2.3/sre.py", line 143, in sub
    return _compile(pattern, 0).sub(repl, string, count)
  File "/usr/lib/python2.3/sre.py", line 257, in _subx
    template = _compile_repl(template, pattern)
  File "/usr/lib/python2.3/sre.py", line 237, in _compile_repl
    p = _cache_repl.get(key)
TypeError: list objects are unhashable



However, I'm sure that the line:

writeln('<entry>%s</entry>' % (procol(col)) )

passes a string to the function... the functions themselves remain 
unchanged...

Given that I'm passing a string to the procol function (as you did in your 
code), surely everything should work?

still stumped :-/


Thanks,

- -- 


Thomi Richards,
http://once.sourceforge.net/


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQE/tp+h2tSuYV7JfuERAhOpAJ0Xectitt44o+jnDK+RyRgKa7lrAACgkGwX
G3EbVq3tGjhGndBPKbjLcbw=
=o4CE
-----END PGP SIGNATURE-----




More information about the Tutor mailing list