On 7/1/2010 3:54 AM, Stephen Hansen wrote:
On 7/1/10 12:45 AM, Terry Reedy wrote:
On 7/1/2010 12:32 AM, Mladen Gogala wrote:
On Wed, 30 Jun 2010 21:04:28 -0700, Stephen Hansen wrote:
However, you can easily get what you want by using the 'reversed'
function (and similarly, the 'sorted' funct
Zubin Mithra wrote:
Er, I don't think you thought that one entirely through (/ tried it
out):
My Apologies.
Here is a working one.
>>> x="123"
>>> t = list(x)
>>> t.reverse()
>>> print ''.join(t)
321
But of course, the method which was suggested earlier is far more elegant.
>
On 7/1/10 5:29 AM, Wolfram Hinderer wrote:
On 1 Jul., 06:04, Stephen Hansen wrote:
The 'reversed' and 'sorted' functions are generators that lazilly
convert an iterable as needed.
'sorted' returns a new list (and is not lazy).
Oops, you're right. Got the two crossed into one in my head.
--
On 1 Jul., 06:04, Stephen Hansen wrote:
> The 'reversed' and 'sorted' functions are generators that lazilly
> convert an iterable as needed.
'sorted' returns a new list (and is not lazy).
--
http://mail.python.org/mailman/listinfo/python-list
Terry Reedy writes:
> sequential statements are a form of composition, even if
> strict functionalists do not like to see it that way.
They actually do like to see it that way:
http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html
--
http://mail.python.org/mailman/listinfo/py
On 7/1/10 12:45 AM, Terry Reedy wrote:
On 7/1/2010 12:32 AM, Mladen Gogala wrote:
On Wed, 30 Jun 2010 21:04:28 -0700, Stephen Hansen wrote:
However, you can easily get what you want by using the 'reversed'
function (and similarly, the 'sorted' function), a la:
>>> y = ''.join(reversed(list(x
On 7/1/2010 12:32 AM, Mladen Gogala wrote:
On Wed, 30 Jun 2010 21:04:28 -0700, Stephen Hansen wrote:
However, you can easily get what you want by using the 'reversed'
function (and similarly, the 'sorted' function), a la:
>>> y = ''.join(reversed(list(x)))
The 'reversed' and 'sorted' func
On Wed, 30 Jun 2010 21:04:28 -0700, Stephen Hansen wrote:
> On 6/30/10 8:50 PM, Mladen Gogala wrote:
> x="quick brown fox jumps over a lazy dog"
> y=''.join(list(x).reverse())
>> Traceback (most recent call last):
>>File "", line 1, in
>> TypeError
>
>
>>
>> Why is TypeError be
> Er, I don't think you thought that one entirely through (/ tried it out):
>
>
My Apologies.
Here is a working one.
>>> x="123"
>>> t = list(x)
>>> t.reverse()
>>> print ''.join(t)
321
But of course, the method which was suggested earlier is far more elegant.
>>> print ''.join(reversed(list(
On Wed, Jun 30, 2010 at 9:09 PM, Zubin Mithra wrote:
> Hello,
>
>> >>> y=list(x).reverse()
>> >>> print y
>> None
>
L = ["a", "b", "c"]
L.reverse()
L
> ["c", "b", "a"]
>
> As you can see, L.reverse() performs the operation on itself and returns
> nothing. Hence, the return type None
Hello,
>>> y=list(x).reverse()
> >>> print y
> None
>
>>> L = ["a", "b", "c"]
>>> L.reverse()
>>> L
["c", "b", "a"]
As you can see, L.reverse() performs the operation on itself and returns
nothing. Hence, the return type None.
Instead of
y=''.join(list(x).reverse())
you should probably do,
>
On 6/30/10 8:50 PM, Mladen Gogala wrote:
x="quick brown fox jumps over a lazy dog"
y=''.join(list(x).reverse())
Traceback (most recent call last):
File "", line 1, in
TypeError
Why is TypeError being thrown? The reason for throwing the type error is
the fact that the internal expressio
If I write things with the intermediate variables like below, everything
works:
>>> x="quick brown fox jumps over a lazy dog"
>>> y=list(x)
>>> y
['q', 'u', 'i', 'c', 'k', ' ', 'b', 'r', 'o', 'w', 'n', ' ', 'f', 'o',
'x', ' ', 'j', 'u', 'm', 'p', 's', ' ', 'o', 'v', 'e', 'r', ' ', 'a', '
', 'l'
13 matches
Mail list logo