Skip to main content

(XLOFT) X-Library of tools

Project description

Logo

XLOFT

(XLOFT) X-Library of tools.

Build Status Docs PyPI pyversions PyPI status PyPI version fury.io
GitHub issues PyPI Downloads GitHub license Code style: Ruff PyPI implementation GitHub repository
Format Top Size Last commit

Currently, the collection is represented by one element `NamedTuple`.

Requirements

View the list of requirements.

Installation

uv add xloft

Usage

from xloft import NamedTuple


nt = NamedTuple(x=10, y="Hello")
# or
d = {"x": 10, "y": "Hello"}
nt = NamedTuple(**d)

nt.x  # => 10
nt.y  # => "Hello"
nt.z  # => raise: KeyError

nt["x"]  # => raise: KeyError
nt["y"]  # => raise: KeyError
nt["x"] = 20  # => TypeError
nt["y"] = "Hi"  # => TypeError

nt.get("x")  # => 10
nt.get("y")  # => "Hello"
nt.get("z")  # => None
nt.get("z", [1, 2, 3] )  # => [1, 2, 3]

nt.x = 20  # => raise: AttributeDoesNotSetValue
nt.y = "Hi"  # => raise: AttributeDoesNotSetValue
nt.z = [1, 2, 3]  # => raise: AttributeDoesNotSetValue

nt.update("x", 20)
nt.update("y", "Hi")
nt.x  # => 20
nt.y  # => "Hi"
nt.update("z", [1, 2, 3])
nt.z  # => [1, 2, 3]

d = nt.to_dict()
d["x"]  # => 10
d["y"]  # => "Hello"

for key, val in nt.items():
    print(f"Key: {key}, Value: {val}")

del nt.x  # => raise: AttributeCannotBeDelete
del nt.y # => raise: AttributeCannotBeDelete

Changelog

View the change history.

License

This project is licensed under the MIT.

Project details


Release history Release notifications | RSS feed

This version

0.1.6

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xloft-0.1.6-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file xloft-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: xloft-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for xloft-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 c7a853f310b8885dc109b27047942b05afebb4f0afdd6614599e7533a6439130
MD5 b7d8bdcedb90a266eb843e5ec04be660
BLAKE2b-256 5662ab50e6f6acea20d3c62c99963549417e01d2d1ab45a5c55ac8f7e3e93e7e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page