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.

In this image made from video, rescue workers remove a python from a toilet outside a home in Chachoengsao, 90km east of the capital Bangkok, May 25, 2016. AP

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.

Get Breaking News Delivered to Your Inbox

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.