C
Colin J. Williams
The Library Reference has
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. If omitted or None, the chars
argument defaults to removing
whitespace. The chars argument is not a
prefix or suffix; rather, all
combinations of its values are stripped: 'example'
Only the last two examples below behave
as expected.
Is it intended that the full range of
characters be handled?
Colin W.
[Dbg]>>> 'ab$%\n\rcd'.strip('%')
'ab$%\n\rcd'
[Dbg]>>> 'ab$%cd'.strip('$')
'ab$%\n\rcd'
[Dbg]>>> 'ab$%cd'.strip('$')
'ab$%cd'
[Dbg]>>> ' ab$%cd '.strip('$')
' ab$%cd '
[Dbg]>>> ' ab$%cd '.strip('%')
' ab$%cd '
[Dbg]>>> ' spacious '.strip()
'spacious'
[Dbg]>>> 'www.example.com'.strip('cmowz.')
'example'
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. If omitted or None, the chars
argument defaults to removing
whitespace. The chars argument is not a
prefix or suffix; rather, all
combinations of its values are stripped: 'example'
Only the last two examples below behave
as expected.
Is it intended that the full range of
characters be handled?
Colin W.
[Dbg]>>> 'ab$%\n\rcd'.strip('%')
'ab$%\n\rcd'
[Dbg]>>> 'ab$%cd'.strip('$')
'ab$%\n\rcd'
[Dbg]>>> 'ab$%cd'.strip('$')
'ab$%cd'
[Dbg]>>> ' ab$%cd '.strip('$')
' ab$%cd '
[Dbg]>>> ' ab$%cd '.strip('%')
' ab$%cd '
[Dbg]>>> ' spacious '.strip()
'spacious'
[Dbg]>>> 'www.example.com'.strip('cmowz.')
'example'