Using re.sub with %s

2010-08-18 Thread Brandon Harris
Having trouble using %s with re.sub test = '/my/word/whats/wrong' re.sub('(/)word(/)', r'\1\%s\2'%'1000', test) return is /my/@0/whats/wrong however if I cast a value with letters as opposed to numbers re.sub('(/)word(/)', r'\1\%s\2'%'gosh', test) return is /my/gosh/whats/wrong Any help

Re: Using re.sub with %s

2010-08-18 Thread Thomas Jollans
On Wednesday 18 August 2010, it occurred to Brandon Harris to exclaim: Having trouble using %s with re.sub test = '/my/word/whats/wrong' re.sub('(/)word(/)', r'\1\%s\2'%'1000', test) return is /my/@0/whats/wrong This has nothing to do with %, of course: re.sub('(/)word(/)', r'\1\%d\2

Re: Using re.sub with %s

2010-08-18 Thread MRAB
Thomas Jollans wrote: On Wednesday 18 August 2010, it occurred to Brandon Harris to exclaim: Having trouble using %s with re.sub test = '/my/word/whats/wrong' re.sub('(/)word(/)', r'\1\%s\2'%'1000', test) return is /my/@0/whats/wrong This has nothing to do with %, of course: re.sub