import pwd


def get_uid(name):
    """Returns an uid, given a user name."""
    try:
        result = pwd.getpwnam(name)
    except KeyError:
        result = None
    if result is not None:
        return result[2]
    return None