def basename(key_or_uri):
    """
    Returns the file name from an S3 URI or key. Mirrors the behavior of the os.path.basename function.

    .. code-block:: python

        >>> import larry as lry
        >>> lry.s3.basename('s3://my-bucket/my-dir/sub-dir/my-file.txt')
        my-file.txt

    :param key_or_uri: An S3 URI or object key
    """
    if '/' in key_or_uri:
        return key_or_uri.split('/')[-1]
    else:
        return key_or_uri