what does the '~' mean in python?

Posted by hidroto on Stack Overflow See other posts from Stack Overflow or by hidroto
Published on 2010-06-12T03:45:10Z Indexed on 2010/06/12 3:52 UTC
Read the original article Hit count: 302

Filed under:
|

what does the '~' mean in python?

i found this BF interpreter in python a while ago.

import sys

#c,i,r,p=0,0,[0]*255,raw_input()



c=0

i=0

p=raw_input()

r=[0]*255





while c<len(p):

    m,n,u=p[c],0,r[i]

    if m==">":i+=1

    if m=="<":i-=1

    if m=="+":r[i]+=1

    if m=="-":r[i]-=1

    if m==".":sys.stdout.write(chr(u))

    if m=="[":

        if ~u:

            while 1:

                m=p[c]

                if m=="]":n-=1

                if m=="[":n+=1

                if ~n:break

                c+=1

    if m=="]":

        if u:

            while 1:

                m=p[c]

                if m=="]":n-=1

                if m=="[":n+=1

                if ~n:break

                c-=1

    c+=1

and i want to know what it does because i want to make one on my ti 84 (and a PF one)

BF is http://en.wikipedia.org/wiki/Brainfuck and PF is something similar

© Stack Overflow or respective owner

Related posts about python

Related posts about interpreter