A curious bit of code...
Ned Batchelder
ned at nedbatchelder.com
Thu Feb 13 22:26:48 EST 2014
On 2/13/14 9:45 PM, forman.simon at gmail.com wrote:
> For the record I wasn't worried about the performance. ;-)
>
> It was for Tkinter event strings not markup tags.
>
> I'm glad this was the time winner!
>
> "key and key[0] == '<' and key[-1] == '>'"
>
>
> Cheers to the folks who did the timings (and saved me from the trouble!)
>
> Last but not least... s[::len(s)-1] omg!!? ;-D
>
If you aren't worried about performance, why are you choosing your code
based on which is the fastest? There are other characteristics
(clarity, flexibility, robustness, ...) that could be more useful.
--
Ned Batchelder, http://nedbatchelder.com
More information about the Python-list
mailing list