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
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
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
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
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
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
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
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
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
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
10 matches
Mail list logo