Norman Khine 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'
>>>

I would like to return:

>>> item_strip
'/company/news'

What is the best way to do this.

Read the manual?
strip( [chars])
Return a copy of the string with the leading and trailing characters removed. The chars argument is a string specifying the set of characters to be removed.
That explains the result you are getting.

It is hard to propose a general solution, as you have given an example rather than a specification.

take a look at the replace method for starters: item_path.replace('/companies', '')

or item_path[len('/companies'):]

or item_path.split('/')[2:]

-- 
Bob Gailer
Chapel Hill NC 
919-636-4239


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

Reply via email to