Re: new string function suggestion

2005-06-13 Thread John Machin
Andy wrote: > What do people think of this? > > 'prefixed string'.lchop('prefix') == 'ed string' > 'string with suffix'.rchop('suffix') == 'string with ' > 'prefix and suffix.chop('prefix', 'suffix') == ' and ' > > The names are analogous to strip, rstrip, and lstrip. But the functionality > is

Re: new string function suggestion

2005-06-13 Thread Raymond Hettinger
[Andrew Dalke] <200 lines of thorough analysis> > To summarize: > - I don't think it's needed that often > - I don't think your implementation's behavior (using an >exception) is what people would expect > - I don't think it does what you expect Wow, that was a remarkably thoughtful,

Re: new string function suggestion

2005-06-13 Thread Steven D'Aprano
On Mon, 13 Jun 2005 07:05:39 +, Andy wrote: > What do people think of this? > > 'prefixed string'.lchop('prefix') == 'ed string' > 'string with suffix'.rchop('suffix') == 'string with ' > 'prefix and suffix.chop('prefix', 'suffix') == ' and ' > > The names are analogous to strip, rstrip, and

Re: new string function suggestion

2005-06-13 Thread Andrew Dalke
Andy wrote: > What do people think of this? > > 'prefixed string'.lchop('prefix') == 'ed string' > 'string with suffix'.rchop('suffix') == 'string with ' > 'prefix and suffix.chop('prefix', 'suffix') == ' and ' Your use case is > I get tired of writing stuff like: > > if path.startswith('html/'