Elektrine lite

← Feed

@nedbat@hachyderm.io

Post #3469252

2026-06-29 11:46 UTC

When thinking about #Python lists vs tuples: lists can be varying lengths and the elements will be treated the same. Tuples are namedtuples without the names. https://nedbatchelder.com/blog/201608/lists_vs_tuples

Replies (2)

  • @Tipa@gamepad.club 2026-06-29 12:11

    @nedbat@hachyderm.io lists in Python can contain dissimilar items.

    Open ##3474454

  • @ancoghlan@mastodon.social 2026-06-29 22:24

    @nedbat@hachyderm.io With type hinting, the cultural difference became a second technical difference (`tuple[int]` is a 1 entry tuple, you have to write `tuple[int, ...]` to indicate arbitrary length, but `list[int]` is inherently arbitrary length and there is no notation for differing types at specific indexes)

    Open ##4245459