Is None more like 0 or -1 ?
Thursday, January 7th, 2010In tinypyC++ every variable is a certain type. In some cases I may have an int x = None; But I’m not sure what that should mean?
What’s the most pythonic? Here’s some anecdotal evidence:
>>> None,None==None,None==-1,None==0,None==1,None==False,None==True,bool(None) (None, True, False, False, False, False, False, False) >>> -1,-1==None,-1==-1,-1==0,-1==1,-1==False,-1==True,bool(-1) (-1, False, True, False, False, False, False, True) >>> 0,0==None,0==-1,0==0,0==1,0==False,0==True,bool(0) (0, False, False, True, False, True, False, False) >>> 1,1==None,1==-1,1==0,1==1,1==False,1==True,bool(1) (1, False, False, False, True, False, True, True)
So .. you can see -1 gets 4/7. 0 also gets 4/7. (1 gets a mere 3/7, so it’s out.)
Anyone care to tilt the scales to -1 or 0?