Skip to main content

A immutable type for Python

Project description

Immutable-Python-type

package for make immutable all types in Python

Support types and replaced by:

  • int = Int_()
  • float = Float_()
  • str = Str_()
  • bool = Bool_()
  • set = Set_()
  • tuple = Tuple_()
  • list = List_()
  • dict = Dict_()

Examples

from immutableType import Bool_, Int_

immutable_bool = Bool_(True) # init immutable boolean
immutable_int = Int_(1) # init immutable integer

immutable_bool.bool_ = 1234 # raise an error
immutable_bool.bool_ = False # good

print(immutable_int == immutable_bool) # print False
"""
Immutable boolean consider True = 1 and False = 0
"""

Int_(integer: int)

from immutableType import Int_

my_int = Int_(1234) # init immutable integer
my_int.int_ # property to get the value in 'int' type

Int_() have methods :

  • __str__ : return string with the integer value
  • __int__ : return the integer value
  • __bool__ : return True if the value == 1 else False
  • __eq__, __and__, __or__, __iand, __ior__ : basic comparaison
  • __add__, __sub__, __iadd__, __isub__, __mul__, __imul__, __truediv__, __itruediv__, __pow__, __ipow__ : basic operation (only int value are accepted for operation. The result of a division is always an integer. Use Float_ class for more precision.)

redaction in progress...

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

immutable_python_type-1.2.2.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

immutable_Python_Type-1.2.2-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file immutable_python_type-1.2.2.tar.gz.

File metadata

  • Download URL: immutable_python_type-1.2.2.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.6

File hashes

Hashes for immutable_python_type-1.2.2.tar.gz
Algorithm Hash digest
SHA256 e8e3e8b3c013d3a073eb2b4f55e938d2aeb509d3662e027d4d541398beb96957
MD5 6a82f69012103f765801d80d68042f73
BLAKE2b-256 e4b57791d2b8fa9580285f11163c374cd3da12a3a543995339a4af63b1cbbeff

See more details on using hashes here.

File details

Details for the file immutable_Python_Type-1.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for immutable_Python_Type-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1ab12dda6fc0ca4f5e2a6dcbc2a4952d94f03682df32414146174f86a9ab0c06
MD5 a1def35b483f6385a9f67580c1d00f6c
BLAKE2b-256 d061a05f1661a0eb81b0dd92d85c3ee5d24a6fdfc5a5ffae18074a0a81c3fcce

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page