osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

A curious bit of code...


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.

--
~Ethan~