That's what I'm doing. Hardwood first, then paint, then carpets.
But if you did carpet first, then paint, it should be okay, too. The painters taped up the carpet edges pretty well, even though I told them I was changing the carpets. I just didn't want their shoes to transfer paint on the new carpets if they were careless when removing the plastic after painting.
If the carpet installers knick some paint off the baseboards, you could just touch it up and it will probably be knicked by the vacuum and furniture later anyways.
BTW, do you already have a hardwood installer? I want to recommend the guys that did my hardwood floors. They were phenomenal and cheaper than other vendors I found on TI. I really appreciate them and am eager to refer them.
Good luck!