[Tutor] (no subject)
Alan Gauld
alan.gauld at btinternet.com
Thu Sep 10 09:51:38 CEST 2009
"C or L Smith" <smiles at worksmail.net> wrote
> Or (and I'll duck after I pass on what I just happened across today on
> the web):
>
> ###
> for i in range(len(word)):
> print word[~i]
> ###
Neat trick!
Now what does ~ do?... the bitwise inverse.
So it relies on the rules of complementing the binary value
to effectively add one and negate. Sneaky, and a new one on me!
Alan G.
More information about the Tutor
mailing list