He’s nothing if not polite.

The bipolar fake lawyer who walked into Manhattan courtrooms last year pretending he was a real attorney was sentenced today to up to 3 years in prison for filing a false instrument and other charges, but took the time to thank the man who prosecuted him.

Terence Kindlon, 42, looked at ADA Daniel Cort and said, sincerely, “Thanks a lot” as he was led out in cuffs.

Kindlon — the heroine-addict son of a prominent Albany lawyer — had walked into a Manhattan courtroom three times at the end of last year impersonating attorney David O’Brien. He faced judges and represented paying clients despite having no law license.

Kindlon pled guilty to a similar scheme in Staten Island and is awaiting his sentencing there.

“This is an incredibly intelligent person with great potential who is thwarted by mental health issues,” said his defense lawyer Stacey Richman.