Ian <hobso...@gmaiil.com> writes: > 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.
Overriding the 'reversed' builtin even in an inner scope is a little bit ugly. If you don't mind some overhead, list(s)==list(reversed(s)) (using the built-in reversed, not the special obscure one) is pretty clear. -- http://mail.python.org/mailman/listinfo/python-list