logoalt Hacker News

Someonelast Thursday at 12:38 PM2 repliesview on HN

> Beautiful. Far more so than Python’s "stressed"[::-1]"

“stressed" [8..1]” Looks better, but IMO is worse, as it requires you to know the length of the string. Change the string and forget to update the indexing expression and you’ve got a (possibly silent) bug.

Having said that, Python IMO may be too powerful here, allowing, for example

   "abcdefghijklmnopqrstuvwxyz”[-5:10:-3]

   'vspm'
Makes perfect sense (from the fifth character from the end, step back 3 characters at a time until you reach the 10th character), but may be too cryptic for some.

Replies

WillAdamslast Thursday at 1:29 PM

Every time I see a manipulation like that, I yearn for LISP and CAR and CDR and so forth...

guenthertlast Thursday at 1:43 PM

Meh, I prefer (reverse "stressed") myself. Say what you mean!