Question: I currently have the following HTML code:

```html
<header style="background-image:url(/images/header.webp)">

```

However, on some browsers (mainly older versions of Safari), [webp is not supported](https://caniuse.com/webp). So I'd like to specify a fallback png image URL.

Using a `picture` tag I can do something like:

```html
<picture>
    <source type="image/webp" srcset="/images/header.webp">
    <source type="image/png" srcset="/images/header.png">
</picture>

```

How can I do the same thing using the `background-image` CSS property?

Note, I can **NOT** use a CSS stylesheet for this, I must use the HTML `style` attribute. This is due to how I'm dynamically generating the HTML content.

Answer: 
If you just want a list of objects at without a shared prefix, specify the delimiter to the filter, and boto3 will filter away the shared prefixes:

```
s3 = boto3.resource('s3')
for obj in s3.Bucket(bucket).objects.filter(Delimiter='/'):
    print(obj.key)

```
You can do this with [s3pathlib](https://s3pathlib.readthedocs.io/en/latest/). It provide an objective oriented interface for S3Path so you can easily create a simple filter function that takes `S3Path` as input argument, and returns `True` / `False` to indicate that if you want to yield it. **This is an example solves your problem**:

```py
from s3pathlib import S3Path

# use tailing / to indicate that it is a dir
p_dir = S3Path("bucket", "root_dir/")

# define a filter
n_parts_of_root_dir = len(p_dir.parts)

def top_level_object(s3path):
    return len(s3path.parts) == (n_parts_of_root_dir + 1)

for p in p_dir.iter_objects(limit=100).filter(top_level_object):
    ... do what ever you want

```

You can also do more advanced filtering or leverage the built-in filters out-of-the box. For example you can filter by attributes like `S3Path.dirname`, `S3Path.basename`, `S3Path.fname`, `S3Path.ext`. See this [document](https://s3pathlib.readthedocs.io/en/latest/04-S3-Object-Filtering/index.html) for more information