palindrome iteration

Ian hobson42 at gmaiil.com
Sat Aug 28 04:48:47 EDT 2010


  On 27/08/2010 21:51, Jussi Piitulainen wrote:
> Meanwhile, I have decided to prefer this:
>
> def palindromep(s):
>      def reversed(s):
>          return s[::-1]
>      return s == reversed(s)
I like this.

s[::-1] is obscure and non-obvious, especially to Python noobs.

This makes it clear what is going on and why at a cost of very little code.

Very helpful to the maintenance programming in 18 months time!

Regards

Ian



More information about the Python-list mailing list