Quick-thinking officers chased down a man who was found to be in possession of heroin and prohibited weapons.
Luke Bradshaw, 25, of Spruce Gardens, Bulwell, admitted charges of possession of a class A drug, possession of a prohibited weapon and possession of a bladed article.
He was sentenced on Monday to 42 months in prison at Nottingham Crown Court.
The court heard how Bradshaw had caught the eye of officers while acting suspiciously in Spruce Gardens, Nottingham, before getting into a taxi.
The taxi was stopped shortly afterwards by officers. Bradshaw ran from the vehicle but was caught and detained a short time afterwards.
A search of Bradshaw found him to be in possession of two wraps of heroin and a machete. A search of his home recovered a cutting agent, scales, wrapping and a stun gun.
As well as the prison sentence, a forfeiture and destruction order was made for the stun gun, machete, scales and the cutting agent.
Sgt Heather Sutton of Nottinghamshire Police said: “The sentencing shows how seriously the court takes matters of drug and knife possession.
“Bradshaw took to the streets of Nottingham with Class A drugs and a machete to hand. With a stun gun also waiting at home, it is fair to say this man is a dangerous individual and the streets of Nottingham are safer without him.”