palindrome iteration

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Aug 29 03:00:10 CEST 2010


On Sat, 28 Aug 2010 15:11:03 +0300, Jussi Piitulainen wrote:

[...]
> When I said that there could be such a method, I was merely objecting to
> a statement, made in response to me, that there could not be such a
> method because strings are immutable. You clearly agree with me that
> that statement was not correct. Would you have let it stand if it was
> made to you?

Ha ha, you're new here aren't you?

> To answer your question, I don't see a real need for .reversed() in
> strings, but I do think .reversed() would be much more useful than
> .swapcase() which is in Python now and for which I see no use at all.

It's hard to disagree with that. I'm not entirely sure what the use-case 
for swapcase is. It's not quite as specialised as sTUdlEycApS but not far 
off.


[...]
> I agree that the gain would be minimal. There is no harm in the method
> either, so I would not object to it if somebody were to propose its
> addition, but just to clarify my position: I have not proposed it.

Then we are in agreement :)

I think the only thing we disagree on is that I think [::-1] is a 
perfectly nice expression for reversal, while you don't. True, it's not 
entirely intuitive to newbies, or self-documenting, you need to learn 
slicing to understand it. But then, if you were Dutch and had not learned 
English, you would probably be looking for a method called omgekeerde and 
would find reverse equally unintuitive.



-- 
Steven



More information about the Python-list mailing list