Possible result:
What you're searching for is called a "Navmesh" and it is done without any python-code.
Therefore you need the Steering-Actuator.
The Seek-Mode makes your object to allways face into the direction of the target and move towards it, until the set distance is reached.
The Flee-Mode is quite the opposite, it makes your object move away from the target, until the set distance is reached.
What you need for avoiding obstacles is the Path following-Mode. This mode uses a mesh that tells your object, where it can move and calculates the fastest way to the target.
1. Create a Navmesh - select every collision objects in your scene, including the floor. Then click on Build Navigation Mesh, which creates you a plane with holes, where your obstacles are. Play around with the Agent-Values if your scene has ramps or different hights...
2. Use the Navmesh by choosing your Navmesh as "Navigation Mesh" in your Steering-Actuator.