re documentation bug?

Tycho Andersen tycho at tycho.ws
Mon Mar 7 22:01:05 EST 2011


Consider the following session:

Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> p = re.compile("foo")
>>> re.sub(p, "bar", "foobaz", flags=re.IGNORECASE)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: sub() got an unexpected keyword argument 'flags'

The flags should really be passed to re.compile() instead. However,
the documentation indicates that they can be passed to re.sub() as
well. Is this a bug, or am I reading things wrong?

http://docs.python.org/library/re.html#re.sub

TIA!

\t



More information about the Python-list mailing list