An excercise in syntax abuse

By Filip Salo; published on June 18, 2009. Tags: python

Or, a random act of senselessness (which is a nice word).

>>> class s(str):
...     def __sub__(self, other):
...         return "".join(chr(c) for c in range(ord(self), ord(other)+1))
... 
>>> s("a") - s("g")
'abcdefg'

Never do this sort of shit. Thank you.