Can you paint the engine bay with the engine still installed?

If you have the chance pull the engine you'll be glad you did. Mines a real ***** to pull so I cleaned and painted around it. I didn't like the way it turned out.