import pwd


def getpw(user):
    """
    Returns the pwd entry for a user given by uid or username.
    """
    if isinstance(user, int):
        return pwd.getpwuid(user)
    return pwd.getpwnam(user)