File size: 385 Bytes
db2c7db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""Reporting what a basket holds.

One function counts the basket to ask whether it is empty, and that is the shape the
truthiness pattern rewrites. The other already asks directly, and the pattern says so.
"""


def describe(items):
    if len(items) == 0:
        return "empty"
    return "full"


def first_or_none(items):
    if not items:
        return None
    return items[0]