rstrip()

Novocastrian_Nomad gregory.j.baker at gmail.com
Fri Jul 16 13:55:14 EDT 2010


On Jul 16, 10:58 am, Jason Friedman <ja... at powerpull.net> wrote:
> $ python
> Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)
> [GCC 4.4.1] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>> "x.vsd-dir".rstrip("-dir")
>
> 'x.vs'
>
> I expected 'x.vsd' as a return value.

One way to achieve the desired result:
'x.vsd-dir'.split('-')[0]



More information about the Python-list mailing list