Various Pythonic simplifications

1. Use xor operator (^) for bitflip
2. Replace "if exp .. true else .. false" with "return expr"
3. String slicing beyond string length works (return empty string)

For (3):

 "[...] However, out of range slice indexes are handled gracefully
 when used for slicing: [...]"

         -- https://docs.python.org/2/tutorial/introduction.html