Nairobi may be safer at times than Cape Town, Johannesburg, Port Moresby... I've stayed at the Utalii training hotel, right by Mathare slums on Thiika Road, and had no trouble (aside from the student housekeepers apparently thinking that the number of towels I got each day should vary randomly between 0 and 2)... but I say this as someone who was born somewhere that leads my country's small cities in manslaughter, robbery, assault and car theft, and went to college somewhere that's one of the top four large cities for manslaughter, robbery and car theft... so my view of things might be skewed.
Kampala feels a lot safer to me, at least. Even smaller towns in Kenya, like Eldoret and Karatina. And "Nairobbery" is in the vocabulary of East Africans, not just tourists.