The highest value pepper spray in a small dispenser you can find - and carry it on your keychain in your hand - ready for use. Get two. Try a can on a target at 1-5yd - pulled from your pocket - make sure you know how to use it and where to aim (FACE). An open knife or a handgun are considered 'brandishing' at the least - assault with intent is likely. Either will likely get you a ride in a police car. The pepper spray will stop attackers, if employed properly, at least giving you the opportunity for a hasty retreat, the absolute best thing to do.
Like ahgar said - know your surroundings - stay out of obvious problem areas - ensure you have good escape routes - and stay vigilante.
Of course, if you are in a 'castle law' state - and on your own property - recall that 'Indiana Jones' had the right idea re protection against a knife/sword-wielding attacker - a 1917 .45ACP revolver. Of course, I'm jaded - I live in Alabama... a clean record all but insures a carry permit. And... I don't go anywhere without either an S&W Airweight in .38 0r .44 Special in my pocket.
My Glock 21 (.45ACP) was under the truck seat when I was working alone as an AMERICORPS volunteer for Habitat for Humanity on a new house just after my retiring from teaching, when three youths - on bicycles - one with a .38 - demanded my wallet. The timely arrival of a plumbing contractor, horn a-blowing, made them scatter. I bought a smaller .45 I could pocket - worked another week - then 'retired' again, a far more sane approach. Stay out of harm's way.
My wife's newest co-teacher friend at work, a 20yr old part-time worker/college student, was car-jacked on the way home from work by two bg's two weeks back. He fought - probably saving his life. They shot him four times - neck, arm, thigh, and stomach. Fortunately, he will have a full recovery. He, like me, was lucky. A knive would have done neither of us any good. Be safe - use the cerebral filter to guide you away from harm.
Stainz