Can gravity be disabled for a single object in the BGE?
You can do that with logic bricks alone. So you do not need a constantly running python script.

Assuming your object has a mass of 1.0:



activated once with an Alyways Sensor [with deactivated True Level Triggering]

Remarks


If you have a different mass and/or gravity, you multiply the gravity with the mass to get the counterforce: Force.z = gravity * mass
Ensure the counterforce is given in global coordinates ([L] must be disabled), otherwise you get a rocket.
Gravity is per convention a force along the global -Z axis. The counterforce must be along +Z (positive Z-coordinate)
Do not wonder that your floating object is moving when touched, that is normal. The only reason it would stop by itself would be air friction. This is not part of the gravity.
This method does not work with swimming/diving objects as the counter force would not be constant.