ot mode='private joke'
story stargaming, I caught it first this time !-)
intrusion pedant=TrueShouldn't that be s-o-r-r-y :-)/intrusion
*ot
--
http://mail.python.org/mailman/listinfo/python-list
Paddy a écrit :
ot mode='private joke'
story stargaming, I caught it first this time !-)
intrusion pedant=TrueShouldn't that be s-o-r-r-y :-)/intrusion
crying
Oui :(
/crying
*ot
--
http://mail.python.org/mailman/listinfo/python-list
OTanswering to Dmitri O.KondratievOT
On Sunday 14 October 2007 5:06:19 pm Dmitri O.Kondratiev wrote:
The function I wrote (below) reverses lists all right:
def reverse(xs):
if xs == []:
return []
else:
return (reverse (xs[1:])) + [xs[0]]
reverse ([1,2,3])
[3, 2, 1]
Bruno Desthuilliers a écrit :
OTanswering to Dmitri O.KondratievOT
(snip)
def reverse(xs):
if xs:
return xs
else:
return (reverse (xs[1:])) + [xs[0]]
I meant:
def reverse(xs):
if not xs:
(etc...)
of course...
ot mode='private joke'
story stargaming, I caught it first
Steven D'Aprano a écrit :
(snip)
def myreversed(sequence):
if isinstance(sequence, basestring):
return type(sequence)().join(reversed(sequence))
else:
return type(sequence)(reversed(sequence))
(in fact, that's so simple I wonder why the built-in reversed() doesn't
On Sunday 14 October 2007 5:06:19 pm Dmitri O.Kondratiev wrote:
The function I wrote (below) reverses lists all right:
def reverse(xs):
if xs == []:
return []
else:
return (reverse (xs[1:])) + [xs[0]]
reverse ([1,2,3])
[3, 2, 1]
Yet when I try to reverse a
On Mon, 15 Oct 2007 02:11:27 -0400, Victor B. Gonzalez wrote:
On Sunday 14 October 2007 5:06:19 pm Dmitri O.Kondratiev wrote:
The function I wrote (below) reverses lists all right:
def reverse(xs):
if xs == []:
return []
else:
return (reverse (xs[1:])) + [xs[0]]
On Oct 15, 2:30 am, Gary Herron [EMAIL PROTECTED] wrote:
Dmitri O.Kondratiev wrote:
The function I wrote (below) reverses lists all right:
def reverse(xs):
if xs == []:
return []
else:
return (reverse (xs[1:])) + [xs[0]]
reverse ([1,2,3])
[3, 2, 1]
Dmitri O.Kondratiev wrote:
The function I wrote (below) reverses lists all right:
def reverse(xs):
if xs == []:
return []
else:
return (reverse (xs[1:])) + [xs[0]]
reverse ([1,2,3])
[3, 2, 1]
Yet when I try to reverse a string I get:
reverse (abc)
Gary, thanks for lots of info!
Python strings are not lists! I got it now. That's a pity, I need two
different functions: one to reverse a list and one to reverse a string:
def reverseList(xs):
if xs == []:
return xs
else:
return (reverseList (xs[1:])) + [xs[0]]
def
Dmitri O.Kondratiev schrieb:
Gary, thanks for lots of info!
Python strings are not lists! I got it now. That's a pity, I need two
different functions: one to reverse a list and one to reverse a string:
Not necessarily, you can handle both cases in one function:
def reverse(xs):
if xs in
On Mon, 15 Oct 2007 13:13:48 +0200, paul wrote:
Dmitri O.Kondratiev schrieb:
Gary, thanks for lots of info!
Python strings are not lists! I got it now. That's a pity, I need two
different functions: one to reverse a list and one to reverse a string:
Not necessarily, you can handle both cases
On 10/15/07, Steven D'Aprano [EMAIL PROTECTED] wrote:
''.join(reversed(abc))
'cba'
list(reversed(range(3)))
[2, 1, 0]
It doesn't take much to make a more user-friendly version:
def myreversed(sequence):
if isinstance(sequence, basestring):
return
On Mon, 15 Oct 2007 14:47:30 +0200, Francesco Guerrieri wrote:
def myreversed(sequence):
if isinstance(sequence, basestring):
return type(sequence)().join(reversed(sequence))
else:
return type(sequence)(reversed(sequence))
(in fact, that's so simple I wonder why the
Dmitri O.Kondratiev wrote:
Gary, thanks for lots of info!
Python strings are not lists! I got it now. That's a pity, I need two
different functions: one to reverse a list and one to reverse a string:
True, they are not both lists, but they *are* both sequences, with some
things in common. In
On 10/15/07, Steven D'Aprano [EMAIL PROTECTED] wrote:
On Mon, 15 Oct 2007 14:47:30 +0200, Francesco Guerrieri wrote:
def myreversed(sequence):
if isinstance(sequence, basestring):
return type(sequence)().join(reversed(sequence))
else:
return
On 10/15/07, Steven D'Aprano [EMAIL PROTECTED] wrote:
On Mon, 15 Oct 2007 13:13:48 +0200, paul wrote:
Dmitri O.Kondratiev schrieb:
Gary, thanks for lots of info!
Python strings are not lists! I got it now. That's a pity, I need two
different functions: one to reverse a list and one to
On 10/15/07, Gary Herron [EMAIL PROTECTED] wrote:
Dmitri O.Kondratiev wrote:
Gary, thanks for lots of info!
Python strings are not lists! I got it now. That's a pity, I need two
different functions: one to reverse a list and one to reverse a string:
True, they are not both lists, but they
The function I wrote (below) reverses lists all right:
def reverse(xs):
if xs == []:
return []
else:
return (reverse (xs[1:])) + [xs[0]]
reverse ([1,2,3])
[3, 2, 1]
Yet when I try to reverse a string I get:
reverse (abc)
...
...
...
File
19 matches
Mail list logo