I buy a new pepper spray for my wife and daughters every year that is an attachment to their key chain. That said, I agree with EJR that it will only effectively stop an attacker who isn't sincerely motivated. Someone on PCP ,whacked out on drugs, or highly intoxicated will not be influenced by it enough to stop an attack.
However, it is very effective in distracting your attacker and providing a moment for retaliation. I've taught my girls when concerned enough to palm the spray into a fist position, their car key (the longest key) is positioned so that it protrudes between their middle and ring finger when holding the spray.
If the attacker fails to be repelled by the pepper spray and continues to move in they will instinctively raise their hand(s) into a holding position to block the stream of the spray from their face. With your free arm sweep their stream blocking arm while stepping in. Punch their neck or under their chin with your key holding fist. If they manage to grab your fist or arm place your leg behind theirs and push forward causing them to go off balance.
If you are carrying a weapon the mass of the keys and spray also make them ideal to distract an attacker by tossing them to the attacker while drawing your weapon to fire. The attackers eyes will instinctively follow the object coming towards him giving you time to draw your weapon with the other hand. The distracting toss works with anything you happen to have handy to throw.
kindredspirit, I'm sure your class went through several defensive moves. Just remember that everything takes practice.