"Erick Tryzelaar" email@example.com wrote in message | On Wed, Mar 5, 2008 at 1:33 PM, Terry Reedy firstname.lastname@example.org wrote: | > >>> [site.replace('http://', '')for site in sites] | > ['www.google.com', 'python.org', 'www.yahoo.com'] | | Unfortunately that would break down in certain cases with a different | strings, like 'foo bar foo'.replace('foo', ''), which just results in | ' bar '.
I knew that, of course, but that objection does not apply to the use case you presented. I simply gave the simplest thing that worked, that passed your 'test'. Tal gave a more general answer.
| > Try another use case. I think str pretty well has the basic tools needed | > to construct whatever specific tools one needs. | | Oh sure it can, considering that I can implement ltrim in three lines. | This is just to reduce a common pattern in my code, and to remove | rewriting it in multiple projects.
Who many such uses are like your 'foo bar for'?