A curious bit of code...
ethan at stoneleaf.us
Thu Feb 13 23:26:12 CET 2014
On 02/13/2014 02:13 PM, Chris Angelico wrote:
> On Fri, Feb 14, 2014 at 8:33 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
>> Oh, it's not that bad! All you have to do is handle the edge case of an
>> empty string:
>> s[::len(s)-1 if s else True]
> And the edge case of the one-character string.
Oops, my description should have said "edge case of a one-character string". The empty string needs no extra handling.
More information about the Python-list