re.sub() bug?

Mike Brown mike at skew.org
Fri Nov 8 04:06:45 EST 2002


Python 2.2.1 on FreeBSD.
These work as expected:

>>> re.sub(u'f', u'b', u'foo')  # keep string as Unicode
u'boo'
>>> re.sub(u'f', u'b', 'foo')   # coerce string to Unicode
u'boo'

But this doesn't work the way I'd think it would:

>>> re.sub(u'f', u'b', u'')     # coerce string to non-Unicode?!
''

So, is this a bug?






More information about the Python-list mailing list