Pyton basic datatypes as a references.
Project description
refdatatypes
Pyton basic datatypes as a references. Solve problems with static class immutable datatypes.
Installation
pip3 install refdatatypes
Problem
class A:
static = 1
class B(A):
pass
print(f"int {A.static}") # get 1 correctly
print(f"int {B.static}") # get 1 correctly
A.static = 5
print(f"int {A.static}") # get 5 correctly
print(f"int {B.static}") # get 5 correctly
B.static = 6
print(f"int {A.static}") # expected 6, but get 5 incorrectly
print(f"int {B.static}") # get 6 correctly
A.static = 7
print(f"int {A.static}") # get 7 correctly
print(f"int {B.static}") # get unchanged 6
Solution
from refdatatypes.refint import RefInt
class AAA:
static = RefInt(1)
class BBB(AAA):
pass
print(f"refint {AAA.static.value}") # get 1 correctly
print(f"refint {BBB.static.value}") # get 1 correctly
AAA.static.value = 5
print(f"refint {AAA.static.value}") # get 5 correctly
print(f"refint {BBB.static.value}") # get 5 correctly
BBB.static.value = 6
print(f"refint {AAA.static.value}") # get 6 correctly
print(f"refint {BBB.static.value}") # get 6 correctly
AAA.static.value = 7
print(f"refint {AAA.static.value}") # get 7 correctly
print(f"refint {BBB.static.value}") # get 7 correctly
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
refdatatypes-1.0.5.tar.gz
(3.4 kB
view hashes)
Built Distribution
Close
Hashes for refdatatypes-1.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 004cb32ee987407f1d8b5185fd45b093c2b359dcae4465cbd370fef4a69f6b44 |
|
MD5 | dfcc0885971d5a4cc2673dfc65b80929 |
|
BLAKE2b-256 | 947b2cd78d133ff0e824c86cc7fae2837f34671a4c480a5be0a45a6814f8af8c |