Is it a bad idea for someone allergic to penicillin safely take keflex, a cephalosporin?

Yes. Cephalexin (keflex) is a first generation cephalosporin and a very close cousin to penicillin. Though it is not 100% true that all penicillin allergic individuals are also allergic to cephalexin, there is a high likelihood of that happening.