Support for __getattr__

Fixes #520.

Implementing `__setattr__` support is considerably more tricky, so I'll do that in a separate PR.