Re: how to convert string function to string method?

2009-12-08 Thread Bruno Desthuilliers
Dr. Phillip M. Feldman a écrit : Bruno- You've made some excellent suggestions, and I'm always grateful for the opportunity to learn. Glad to know I've been of any help !-) My revised code appears below. Philllip def strip_pairs(s, open='([{\'', close=')]}\''): OVERVIEW This

Re: how to convert string function to string method?

2009-12-07 Thread Peter Otten
Dr. Phillip M. Feldman wrote: I wrote a handy-dandy function (see below) called strip_pairs for stripping matching pairs of characters from the beginning and end of a string. This function works, but I would like to be able to invoke it as a string method rather than as a function. Is

Re: how to convert string function to string method?

2009-12-07 Thread r0g
Dr. Phillip M. Feldman wrote: I wrote a handy-dandy function (see below) called strip_pairs for stripping matching pairs of characters from the beginning and end of a string. This function works, but I would like to be able to invoke it as a string method rather than as a function. Is this

Re: how to convert string function to string method?

2009-12-07 Thread Bruno Desthuilliers
Dr. Phillip M. Feldman a écrit : I wrote a handy-dandy function (see below) called strip_pairs for stripping matching pairs of characters from the beginning and end of a string. This function works, but I would like to be able to invoke it as a string method rather than as a function. Is this

Re: how to convert string function to string method?

2009-12-07 Thread Steven D'Aprano
On Sun, 06 Dec 2009 22:47:48 -0800, Dr. Phillip M. Feldman wrote: I wrote a handy-dandy function (see below) called strip_pairs for stripping matching pairs of characters from the beginning and end of a string. This function works, but I would like to be able to invoke it as a string method

Re: how to convert string function to string method?

2009-12-07 Thread Bruno Desthuilliers
r0g a écrit : (snip) I've never tried it but I think it is possible to inject new methods into existing classes, see... Doesn't work for most builtin types - for both performances and sanity reasons. -- http://mail.python.org/mailman/listinfo/python-list

Re: how to convert string function to string method?

2009-12-07 Thread Terry Reedy
Steven D'Aprano wrote: On Sun, 06 Dec 2009 22:47:48 -0800, Dr. Phillip M. Feldman wrote: I wrote a handy-dandy function (see below) called strip_pairs for stripping matching pairs of characters from the beginning and end of a string. This function works, but I would like to be able to invoke

Re: how to convert string function to string method?

2009-12-07 Thread Dr. Phillip M. Feldman
and last character from `s`: s= s[1:-1] return s -- View this message in context: http://old.nabble.com/how-to-convert-string-function-to-string-method--tp26673209p26688035.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman

how to convert string function to string method?

2009-12-06 Thread Dr. Phillip M. Feldman
this message in context: http://old.nabble.com/how-to-convert-string-function-to-string-method--tp26673209p26673209.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list

Re: how to convert string function to string method?

2009-12-06 Thread Stephen Hansen
On Sun, Dec 6, 2009 at 10:47 PM, Dr. Phillip M. Feldman pfeld...@verizon.net wrote: I wrote a handy-dandy function (see below) called strip_pairs for stripping matching pairs of characters from the beginning and end of a string. This function works, but I would like to be able to invoke it