(XLOFT) X-Library of tools
Project description
XLOFT
(XLOFT) X-Library of tools.
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
len(nt) # => 2
nt.keys() # => ["x", "y"]
nt.values() # => [10, "Hello"]
nt.has_key("x") # => True
nt.has_key("y") # => True
nt.has_key("z") # => False
nt.has_value(10) # => True
nt.has_value("Hello") # => True
nt.has_value([1, 2, 3]) # => False
nt.get("x") # => 10
nt.get("y") # => "Hello"
nt.get("z") # => None
nt.update("x", 20)
nt.update("y", "Hi")
nt.x # => 20
nt.y # => "Hi"
nt.update("z", [1, 2, 3]) # => raise: KeyError
d = nt.to_dict()
d["x"] # => 10
d["y"] # => "Hello"
for key, val in nt.items():
print(f"Key: {key}, Value: {val}")
nt["x"] # => raise: KeyError
nt["y"] # => raise: KeyError
nt["z"] # => raise: KeyError
nt["x"] = 20 # => TypeError
nt["y"] = "Hi" # => TypeError
nt["z"] = [1, 2, 3] # => TypeError
nt.x = 20 # => raise: AttributeDoesNotSetValue
nt.y = "Hi" # => raise: AttributeDoesNotSetValue
nt.z = [1, 2, 3] # => raise: AttributeDoesNotSetValue
del nt.x # => raise: AttributeCannotBeDelete
del nt.y # => raise: AttributeCannotBeDelete
Changelog
License
This project is licensed under the MIT.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
xloft-0.1.9-py3-none-any.whl
(5.1 kB
view details)
File details
Details for the file xloft-0.1.9-py3-none-any.whl.
File metadata
- Download URL: xloft-0.1.9-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79432e0e792160d419b5816918417f7dd60e6cf8751b4868004c9282bee2a2ce
|
|
| MD5 |
31e7b2ed74ccb1000f669555a5a4eef8
|
|
| BLAKE2b-256 |
7e07e5ea4434bbb80f8543d8e942dde476449bbd1bc7be4309406f16713c99f0
|