Login
You're viewing the ruby.social public feed.
  • Ryanyantor3d@mas.to
    Nov 1, 2026, 7:13 PM

    @compfu I usually do this

    ```python
    item = (items or [None])[0]
    ```

    or this

    ```python
    item, *_ = items or [None]
    ```

    As a bonus it also handles the situation where `items` is None in case you're working against an API that returns None instead of an empty list.

    Not that any API would ever do something so heinous. maya.

    💬 0🔄 0⭐ 1