Any other Python flaws?

D-Man dsh8290 at
Mon Jun 18 20:49:34 CEST 2001

On Fri, Jun 15, 2001 at 02:18:04PM -0500, Michael Chermside wrote:
| Martijn writes:
| > Further things possibly wartlike, though this one never bit me, is
| > the possibly to assign to None, definitely a weird idea when you
| > first encounter it.

[other questions/points already answered]

| Oh well... at least people don't bump into this one much. And if you
| accidently clobber it, you can restore things with:
| def __None():
|     pass
| None = __None()

Well, that doesn't work.  One of the key features of 'None' is that
there only ever exists a single instance.  This would create a new,
unique, instance bound to (a more local) 'None'.

    id( None ) != id( __builtins__.None )
    id( None ) != id( other_module.None )

which results in (if, for some reason, None was returned instead of
raising an exception -- maybe it isn't always failure but only to this

    foo = other_module.func()
    if foo is None :
        print "failed"
    else : 
        print "success"

not working.  Also, 

    foo = other_module.func()
    if foo == None :
        print "failed"
    else : 
        print "success"

wouldn't work because the None's are instances of different classes
and don't define a comparision function that makes them equal.


More information about the Python-list mailing list