On Wed, Dec 24, 2008 at 7:25 AM, Norman Khine <nor...@khine.net> wrote:
>
> Hello,
> I have difficulties in trying to stripping the following:
>
>>>> item_path = '/companies/company/news'
>>>> item_strip = item_path.strip('/companies')
>>>> item_strip
> 'y/new'

strip() doesn't do what you want. It removes any of the characters in
the given string, in any order.

> I would like to return:
>
>>>> item_strip
> '/company/news'
>
> What is the best way to do this.

To remove a fixed string use slicing:
item_strip = item_path[len('/companies'):]

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to