A Canberra serial child molester has been sentenced to seven-and-a-half years in jail for the public rape of a three-year-old girl and the racially motivated bashing of his neighbour.

In September, Shane Williams, 40, from Campbell, was making his way to a police station for his annual sex offender check-in when he decided to stop at the Belconnen Library to use the toilets.

He was browsing the books inside when a three-year-old girl wandered over to him and said hello. He then sexually assaulted her.

The child's mother was just metres away using a computer and did not initially notice that her daughter had wandered off.

She screamed when she spotted the toddler nearby in the arms of a crouching Williams.

Today in the ACT Supreme Court, prosecutor Sara Gul described the attack as despicable.

"It's clear that he is a significant danger to the community," Ms Gul said, before detailing Williams' extensive history of sexual assaults against young children stretching back more than two decades.

"He really is what can only be described as a chronic child molester."

Williams' lawyer James Sabharwal agreed the attack was concerning and offered his client's only excuse that he was both drunk and high on drugs at the time.

"The only saving grace I can put to your honour is that the little girl was not required to give evidence," Mr Sabharwal said.

Chief Justice Helen Murrell said it was difficult to know if the victim would suffer any future impacts from the assault.

"She was too young to understand concepts such as stranger danger," Ms Murrell said.

"But one would have expected in those circumstances that their daughter would have been safe."

Williams also bashed his neighbour

Williams was on bail at the time of the rape for bashing his neighbour.

Police documents read to the court reveal that in November 2012 Williams became upset with his neighbour over his African appearance.

Williams started whingeing at him about how he was trying to take over his country before launching into an unprovoked attack.

He punched the man several times and left him in hospital for three days, requiring plastic surgery to his face.

"He is a danger to the community, to the most vulnerable people in the community," Ms Murrell said.

For both the assault and the rape, Williams received a 25 per cent discount on his sentence for pleading guilty.

Ms Murrell sentenced him to a total of seven years and six months in prison.

He will be eligible for parole in four-and-a-half years.