python re.sub
Ivan Van Laningham
ivanlan at callware.com
Thu May 6 17:20:08 EDT 1999
Pythonistas, Jerry--
"Andrew M. Kuchling" wrote:
>
> Ivan Van Laningham writes:
> >"Jerry L. Bash" wrote:
> >> At any rate, the following is mostly taken from the HOWTO. It appears
> >> that the default 'count' is not working as I expected, resulting in
> >> not making substitutions for all cases.
> >>
> >> Python 1.5.2 (#2, Apr 26 1999, 09:21:48) [GCC 2.8.1] on irix646
> >> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >> >>> import re
> >> >>> p = re.compile( '(blue|white|red)')
> >> >>> p.sub( 'colour', 'blue socks and red shoes')
> >> 'blue socks and red shoes'
>
> After looking at re.py a bit, here's a suggestion: What does
> 'import sys ; print sys.maxint' output? The re.py code contains a
> statement like "if count==0: count = sys.maxint", and I'm wondering if
> perhaps sys.maxint is coming out negative, which would explain these
> symptoms. Why sys.maxint might be negative, I don't know.
>
On Linux (1.5.2c1) and NT (1.5.2) it prints the correct value:
2147483647. Non-negative.
Jerry? What do you show?
<-maxint>-ly y'rs,
Ivan
----------------------------------------------
Ivan Van Laningham
Callware Technologies, Inc.
ivanlan at callware.com
http://www.pauahtun.org
See also:
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps: Cu Chi, Class of '70
----------------------------------------------
More information about the Python-list
mailing list