Skip to main content

Bynd is a way of introducing static typing to Python.

Project description

                            ██████╗ ██╗   ██╗███╗   ██╗██████╗ 
                            ██╔══██╗╚██╗ ██╔╝████╗  ██║██╔══██╗
                            ██████╔╝ ╚████╔╝ ██╔██╗ ██║██║  ██║
                            ██╔══██╗  ╚██╔╝  ██║╚██╗██║██║  ██║
                            ██████╔╝   ██║   ██║ ╚████║██████╔╝
                            ╚═════╝    ╚═╝   ╚═╝  ╚═══╝╚═════╝

A module which allows binding data to one or more kind.

Bynd's intended use, is to be assigned to a variable.

Which, in this case, the variable can still be used

exactly the same way just by accessing the 'data'

class attribute. Since 'Bynd' "binds" the data to

a single type, the data cannot be modified

causing it to be constant and forces the programmer

to create references which can be modified. Inner

collection types can be specified using the 'inner'

keyword argument and passing it a 'set' of types, to

which the collection elements will be bound.

The benefits of using Bynd are:

  1. Runtime type checking

  2. Constant data

  3. Ability to access the Bynd info with the 'info' class attribute just the data itself from the variable in which it is stored using the 'data' attribute


Bynd: Basic Usage

# filename: Bynd_test.py
from Bynd.bynd import Bynd

# Instantiates a Bynd object and binds the data [1,2,[3,4,5]] to the type 'list'
# and it also binds the inner elements to the type 'list' and 'int' for both lists
my_variable = Bynd([1,2,[3,4,5]], list, inner={list, int})  # the data can't be changed

# The above code will raise a 'ByndError' if the data is not of type 'list'
# and if the inner elements are not of type 'list' or 'int'

# To access the data, we can use the dot '.' operator to access the 'data' class attribute
print("my_variable.data: ", my_variable.data)

# The 'data' and 'types' can be accessed using the '__info__' class attribute.
print("my_variable.info: ", my_variable.info)

# Output:
#    my_variable.data: "some string"
#    my_varaible.info: [([1,2,[3,4,5]], <class 'list'>, {<class 'list'>, <class 'int'>})]

NOTE:

Bynd, automatically performs recursive type checking. What that means is, for any

collection type (list, tuple, set, etc.) it encounters, collection element types

are checked against the type set. All types need to be known or assumed when using

'Bynd'. It also does not make use of type hints in any way and it introduces strict

typing to Python by striping some of its flexibility.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

bynd-1.7-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file bynd-1.7-py3-none-any.whl.

File metadata

  • Download URL: bynd-1.7-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for bynd-1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ea95c29cc0d4d8b2caaec5f87399687bc1d19bd65293067c49d50e784fe11cd0
MD5 a5920dccf415dfd3b9e00f3d0c4b88fc
BLAKE2b-256 935953eb7fd7ee97788b8144a6f440af8122dcaa110295b844ff5da4d1c6f2d8

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