BANGKOK — A Thai man is recovering from a bloody encounter with a 10-foot python that slithered through the plumbing of his home and latched its jaws onto his penis as he was using a squat toilet.

Attaporn Boonmakchuay was smiling as Thai television stations interviewed him in his hospital bed about the intimate intrusion, and doctors said he would recover. But photos of his blood-splattered bathroom in Chachoengsao province, east of Bangkok, were testimony to his ordeal.

The 38-year-old told Thai TV Channel 7 that he struggled to remove the snake for 30 minutes Wednesday before he managed to free himself with help from his wife and a neighbor. After his wife tied a rope around the snake, Attaporn pried open its jaws before passing out.

Emergency workers dismantled the Asian-style squat toilet, with the python still twined through it. The snake was taken away to be released back into the wild, according to an emergency responder cited by the newspaper Thai Rath.

Doctors said Attaporn, bloodied but unbowed, will recover.

“He has a really good attitude … even though his own wife and children were in shock. He’s been smiling and giving interviews all day from his bed,” hospital director Dr. Chutima Pincharoen said.

Watch to see how penises are being transformed in the digital age.