[Tutor] strip is deprecated, so what do I use?

William O'Higgins william.ohiggins at utoronto.ca
Tue May 24 19:31:48 CEST 2005


On Tue, May 24, 2005 at 01:16:21PM -0400, Michael P. Reilly wrote:
>   On 5/24/05, William O'Higgins <[1]william.ohiggins at utoronto.ca> wrote:
>
>     As the subject says, I was looking for an analog to chomp, and found
>     strip() and friends (rstrip() and lstrip()), but they are deprecated.
>     I'm happy to forgo their use in preparation for 3.0 (I figure we're
>     going to live the rest of our lives in the future, we might as well be
>     ready) but I need an alternative syntax today, and I haven't been able
>     to see what I should use instead.  Anyone have a suggestion?
>
>   William,
>
>   These were all changed to object-oriented syntax on the string value
>   itself.
>     Old way          string.strip('   abcd   ')
>     New way          '   abcd   '.strip()
>
>   It may take a little getting used to, but the functionality is the same
>   and it is more in keeping with how we should be treating the built-in data
>   values as objects just like we do with class instances.

Perfect, and it make a lot of sense.  Heck, I find this much more
readable in terms of nested calls.  Thank you.
-- 

yours,

William

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.python.org/pipermail/tutor/attachments/20050524/8cd4426a/attachment.pgp


More information about the Tutor mailing list