Python

Write an awesome doc for Python. A very nice an practical one extracted from Python official documentation.

View on GitHub

Unpacking objects in Python

person = {
    'name': 'Alice',
    'age': 30,
    'city': 'New York'
}

name, age, city = person.values()
print(f"{name=}, {age=}, {city=}")
# Output: name='Alice', age=30, city='New York'

age, city, name = person.values()
print(f"{name=}, {age=}, {city=}")
# Output: name='New York', age='Alice', city=30

_, age, city = person.values()
print(f"{age=}, {city=}")
# Output: age=30, city='New York'