Skip to content

📸 Query Representation🔗

One of the pain points of working with lazy iterator (e.g., generators) is that they are not "inspectable". That is, you can't see what's inside it, without consuming it. This makes it hard to debug, and hard to understand what's going on, which eventually slows down development.

Fliq solves this problem by providing a repr method for queries, which returns a string representation of the query, including peeking (see peeking) into the query without consuming it.

repr()🔗

Returns a string representation of the query, while peeking at actual elements within the query. Query stays intact (i.e., no items are consumed). If representation is long, only the first 10 elements are shown, followed by an ellipsis. Elements are represented using their repr function. Inner iterable is represented as a list.

Examples:

>>> from fliq import q
>>> q(range(10))
Query([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> q(range(100))
Query([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...])
>>> q([])
Query([])
>>> repr(q(range(3)))
'Query([0, 1, 2])'

Returns:

  • str –

    A string representation of the query.