Super Collections

0.6.2 · active · verified Fri Apr 10

Super Collections is a Python library (current version 0.6.2) that provides enhanced data structures, `SuperList` and `SuperDict`, which are designed for deeply nested data, similar to JSON or YAML structures. It offers features like recursive conversion of Python data structures, convenient dot-based access to nested elements, and a `super_collect()` factory function for easy instantiation. The library aims to simplify working with complex, nested collections and is actively maintained.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create `SuperDict` and `SuperList` instances using the `super_collect` factory function and access nested data using convenient dot notation.

from super_collections import super_collect, SuperList, SuperDict

# Create a SuperDict from a regular Python dictionary
data = {'user': {'name': 'Alice', 'details': {'age': 30, 'city': 'NY'}} }
sd = super_collect(data)

# Access nested elements using dot notation
print(f"User name: {sd.user.name}")
print(f"User city: {sd.user.details.city}")

# Create a SuperList from a regular Python list
items = [1, {'product': 'Laptop', 'price': 1200}, 3]
sl = super_collect(items)

# Access elements in a SuperList
print(f"First item: {sl[0]}")
print(f"Product name: {sl[1].product}")

# Modify elements
sd.user.details.age = 31
print(f"Updated age: {sd.user.details.age}")

view raw JSON →