Well... its true that its more expensive, but its true that the "sister" of D40 would be maybe EOS 350D, anyway. Particulary i like about 400D the system for cleaning lens and the quality of image, and also that its one of the cameras with less noise, even with quite high ISO.
What i dont like is that the visor is small and with little data and... it doesnt have puntual measuring (that i still dont understand why).
About Nikon D40, it has "just" 6 mpx, its maybe a little small and the quality of the plastic of the body is not as good as i would like it to be, but for the rest is very very nice DSLR for starting and shooting in a very nice way

(I cant avoid it, im fan of Nikon)