Rewrite value() to accept attribute names and indices, and added a docstring.