None over null in python

In Python checking whether a variable is assigned isn’t possible by asking
if enemy != null: pass

Instead the expression is:
if enemy != None: pass

The findNearestEnemy methods contain a description that says they return “null” when no enemy is available. It would be more appropriate if they would say that “None” gets returned.

Why that complicated?

if enemy:

checks if the enemy-object exists and passes when it does. A non-existing object is falsy, while every non-null value is falthy.

Yes, it works that way. But that still doesn’t justify the help text talking about null.

The problem you are having is that the item descriptions are language agnostic. So, it says “null”. You not being agnostic are using (and assuming) python but there is no null in python, instead python calls it None (and it is an actual object) but what about the languages that use nil instead of null. (if any singleton should win it would be nil, since three of the six languages use that. (3 nil, 2 null, and one None)) :smile:

I don’t see this changing since it would have to be replaced with null/None/nil/whatever everywhere it is used. I can see it being changed to say ‘null’ instead of null. so that it looks less like a keyword and more like a concept. (the later glasses just say null instead of having it box-highlighted, that may have been a mistake, but one we should run with.) :wink:

I believe that the coco examples use/teach the construct that J_F_B_M suggested…

Please check the python doc page, if this page doesn’t explain that python uses “None” not “null” then it needs to be added, there.