A collection of classes that encapsulate a primitive so it can be modified inside a function.
Project description
Mutaprim
Mutaprim is very simple package containing a single module: mutaprim
. The module contain 5 "mutable primitive" types,
all inheriting from a base class called MutablePrimitive
:
MutableBool
MutableInt
MutableFloat
MutableStr
MutableBytes
An instance of any MutablePrimitive
subclass will have the value
property, as well as equivalent get
and set
functions.
Here is a very simple demonstration:
from mutaprim import MutableInt
def increment(integer: MutableInt):
integer.value += 1
# `__init__` and `__str__`
mutable_int = MutableInt(0)
print(mutable_int) # 0
# `get` and `set`
mutable_int.set(10)
print(mutable_int.get()) # 10
# `value`
increment(mutable_int)
print(mutable_int.value) # 11
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 Distribution
mutaprim-0.1.0.tar.gz
(6.1 kB
view details)
File details
Details for the file mutaprim-0.1.0.tar.gz
.
File metadata
- Download URL: mutaprim-0.1.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a62d0bd00034ab8d5b827846cf4e724d0cde095a78a7e208bf7262f81ef2516 |
|
MD5 | 3412ff2b8034c5271dfeee9e3367707e |
|
BLAKE2b-256 | 1723e8da8c5bc31caf6105cb2da92ed6ed87eca984d35df61ed030ba95fd45f3 |