jpiitula at ling.helsinki.fi
Sat Aug 28 14:34:07 CEST 2010
Paul Rubin writes:
> Ian 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.
Thanks for that. I'm beginning to like it - not its overhead but
certainly its natural clarity. It wins over ''.join(reversed(s))
easily, in my eyes.
More information about the Python-list