Cats - cat claws


I have a question to the people who have or have had cats as pets. I love cats and want one but I know sometimes they do that thing with their nails where they push them out or something and it hurts like hell if they grab your leg with it (it’s happened to me). So is their anything I can do to avoid that? I asked at petsmart and the girl mentioned some sort of cover that can go over the nails. But is that comfortable for the cat? Has anyone used that? I wouldn’t want to file the nails or anything because I know they use them to defend themselves outside. Or is it just not avoidable.