def get_many(d, required=[], optional=[], one_of=[]):
d = d or {}<EOL>r = [d[k] for k in required]<EOL>r += [d.get(k)for k in optional]<EOL>if one_of:<EOL><INDENT>for k in (k for k in one_of if k in d):<EOL><INDENT>return r + [d[k]]<EOL><DEDENT>raise KeyError("<STR_LIT>")<EOL><DEDENT>return r<EOL>
Returns a predictable number of elements out of ``d`` in a list for auto-expanding.

Keys in ``required`` will raise KeyError if not found in ``d``.
Keys in ``optional`` will return None if not found in ``d``.
Keys in ``one_of`` will raise KeyError if none exist, otherwise return the first in ``d``.

Example::

    uid, action, limit, offset = get_many(request.params, required=['uid', 'action'], optional=['limit', 'offset'])

Note: This function has been added to the webhelpers package.