A Thai man is recovering in hospital after a 3m (10ft) python emerges from a squat toilet and attacks a man in Bangkok.