Skip to main content

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


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.1.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

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

refdatatypes-1.0.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file refdatatypes-1.0.1.tar.gz.

File metadata

  • Download URL: refdatatypes-1.0.1.tar.gz
  • Upload date:
  • Size: 2.4 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

Hashes for refdatatypes-1.0.1.tar.gz
Algorithm Hash digest
SHA256 63e340a7522a021f072e4743a3b44f5f2b246f3cbe1635b88c77e7d7fefe0594
MD5 ecd57a85f59596730f685625f128fab0
BLAKE2b-256 680f4d80392e5655b91392b4a4cc6a1ea164237fec7bca417577e5b1cc3a2595

See more details on using hashes here.

File details

Details for the file refdatatypes-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: refdatatypes-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.6 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

Hashes for refdatatypes-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 659d7df7371b401c8a94f4d46b2957a52a2335aa513fd4402df6c603f3d3d95f
MD5 3177339c8fbad4ed32186ab8f6b553bd
BLAKE2b-256 9790dcf4f8cbea4dc61ac7beb4e07f6e35f612e198bf124b2db5c5a61ecf8791

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