Skip to main content

Utils for simplifying work with classes

Usage:

pip install class-utils


Properties:

  1. default_property
  2. default_getter
  3. typed_property

Mixins:

  1. DefaultRepresentationMixin

default_property

from class_utils import default_property


class Point():
    x = default_property('x')
    y = default_property('y')

    def __init__(self, x, y):
        self.x = x
        self.y = y


point1 = Point(1, 4)

print(point1.x) # => 1

point1.x = 3
print(point1.x) # => 3

default_getter

from class_utils import default_getter


class Point():
    x = default_getter('x')
    y = default_getter('y')

    def __init__(self, x, y):
        self._x = x
        self._y = y


point1 = Point(1, 4)

print(point1.x) # => 1

typed_property

from class_utils import typed_property


class Person():
    name = typed_property('name', str)

    def __init__(self, name):
        self.name = name


person1 = Person('Bill')
print(person1.name) # => 'Bill'

person1.name = 123 # => TypeError: name must be a <class 'str'>

DefaultRepresentationMixin

from class_utils import default_property, DefaultRepresentationMixin


class Date(DefaultRepresentationMixin):
    day = default_property('day')
    month = default_property('month')
    year = default_property('year')

    def __init__(self, day, month, year):
        self.day = day
        self.month = month
        self.year = year


date1 = Date(12, 12, 2012)
print(date1) # => Date({'_day': 12, '_month': 12, '_year': 2012})

Metadata

Release files for class-utils 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for class-utils 0.0.5
File Size Uploaded Provenance Actions
class-utils-0.0.5.tar.gz 2.1 kB Without provenance Details for class-utils-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for class-utils 0.0.5
File Interpreter ABI Platform Actions
class_utils-0.0.5-py3-none-any.whl Python 3 none any Details for class_utils-0.0.5-py3-none-any.whl

Total release size: 5.4 kB

Release files / class-utils-0.0.5.tar.gz

Download URL class-utils-0.0.5.tar.gz
Size 2.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1ec1c04d51e79dfa2fde856a59b47502469059fe5307c16f44b60b1eae769212
BLAKE2b-256 checksum
How to use checksums
e122341d1030516fff90985651044f1a7b39a7e418a367f87c6f9020c612783b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release files / class_utils-0.0.5-py3-none-any.whl

Download URL class_utils-0.0.5-py3-none-any.whl
Size 3.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d1bc595ce681729c2631666077a98ec07d648ca6962159c6331eb236acca877
BLAKE2b-256 checksum
How to use checksums
dc884c47f811821be5a40cd444dcc20a90294c89b9c89f45c6084382a58d18e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Security for class-utils 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page