It's the stuff nightmares are made of.

You're at your most vulnerable, sitting on the toilet at home late at night, when something slithers its way onto your leg and tries to attack you.

That was the situation at one Sunshine Coast house on Monday, when a teenage boy on a late-night toilet run unintentionally cornered a carpet python that had found its way into the bathroom.

Noosa snake catcher Luke Huntley, who came out to retrieve the reptile, said the 17-year-old boy was oblivious to the six-foot python sitting next to the bowl.

"He literally sat down, and he felt this cold, big, strong thing starting to wrap around his leg. He looked down and it's a python," Mr Huntley said.

"He goes to move his leg, and it strikes towards his leg. He flicks it off with its other foot, and it sort of recoils.

"So he pulls his pants up, and he runs out of there and closes the door behind him.

"His mum said she tried to move it on herself, but it kept striking at her."

Mr Huntley said the snake's aggressive manner could be chalked up to a combination of things — it was in hunt mode and looking for a feed, and it had been cornered.

"The snake knew there was no way out, so it was literally was fight or flight," he said.

"It had to fight because it couldn't run away, and that's what the snake did.

"It's an unusual behaviour for a snake to wrap around a person and try and strike."

Mr Huntley said it was lucky the boy was not bitten.

"[The python] wasn't small, a bite from that one would've really hurt."

The snake even tried to have a go at him.

"When I got there it was in a grumpy mood. When I was putting it in the bag it struck up at my hand," Mr Huntley said

This was not the first time Mr Huntley's been called out to retrieve a snake from the toilet, but he's never come across something as big or aggressive as this one.

"This is the stuff nightmares are made of. Of all the places to have that happen, when you're at your most vulnerable," he said.

The snake catcher said the boy was OK following his close encounter.

"I think he's going to make sure all the doors and windows are always closed now, that's how a snake would've got in," he said.

"They leave the garage and doors open for the dogs."