Not really. The only difference is that pre-setup properties (via GUI) are not in the KX_GameObject.attrDict. I guess it is a bug and nobody uses this dict :D.
The whole problem is a timing thing. In that way you can be lucky that you discovered it at this early stage.
When you add a new object it has the pre-setup properties only.
Your code expects the property “total_distance” set within the game object. But this code runs via a different game object as you mentioned before.
The code at the game object which set the property was not running at that time. That means the property is not present (similar to an undeclared variable) but you assume it is.
A) Make sure the properties is always set (by setting it in GUI)
B) Deal with the non-existent property
This is a design issue. You have a dependency from the “evaluating” game object to the “setting” game object.
What is it that you need? Obvious you want to check a distance.
Where does the distance come from? Something calculated it before hand and stored it in this property.
As this calculation is not triggered explicitly when needed you have to deal with the situation that this information is not present.
If there is no other reason to store the distance in the property it might be a better idea to perform the distance calculation when you need it.
You have to organize everything by yourself. It separates the men from the boys ;).
Make sure you keep your organization consistent within the single game.
A good organization is to separate different things and to keep things together that belongs together.
User UI can be in organized one or more modules (Mouse, keyboard, menu).
Game Logic should be kept separate from any UI logic, SaveLoad, Network or Selection methods etc.
Think as you want to use your code in a different game (there is no need to reinvent the wheel all the time)
If you are unsure. Try to implement your idea in a test file first. It should only contain the Logic you want to develop plus some test logic.
This makes it easier to concentrate on the single logic (rather than to deal with all side effects of other logic).
It makes it easier to identify and solve problems.
You can distribute the test file if you need help. As it does not contain irrelevant things it is much easier for us to help you.