Base on these two camera, I think Canon powershot G9 is suitable for the beginner. It is more easy to control. If you really not understand how to use, you also can choose the auto mode to take the photos at that time.
As for the Canon EOS 40D,it is for the photographer or some users whom have enough knowledge, skill and experience.
On my opinion, I recommend you to buy the Canon Digital IXUS 860 IS,Canon Digital IXUS 950 IS and Canon Digital IXUS 960 IS. These three cameras are more suitable for a beginner. Moreover, their weight are very light for carry outside.