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}") # expected 7, but get unchanged 6, incorrectly
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
More details you can find in included examples static_class_attribute_problem.py and static_class_attribute_solution.py .
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.7.tar.gz
(3.5 kB
view details)
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
File details
Details for the file refdatatypes-1.0.7.tar.gz.
File metadata
- Download URL: refdatatypes-1.0.7.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39f2e8d347b03b978811b1b2af3b0643cf662d94ee24f5939c372b9578f140e4
|
|
| MD5 |
de5580e48ed1c09449ac85cf155ea1cc
|
|
| BLAKE2b-256 |
dae255381148be8ed3dd6032bda7632e19c97d811dee877e41d3b3c451f04ec0
|
File details
Details for the file refdatatypes-1.0.7-py3-none-any.whl.
File metadata
- Download URL: refdatatypes-1.0.7-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8be4a3419c04b57f52ba0cc789459cf00e58548b5bc5d2097576f0910b0d0c4a
|
|
| MD5 |
5214fc7621f1fd91a243c8803afb99ae
|
|
| BLAKE2b-256 |
50a3e559ec390580ba7c11072a0f4bdbabc488f7dd58baf415ef17fb8f808b59
|