Skip to main content

A class that extends a class into a dictionary like object whose members can be accessed by dot notation.

Project description

Class to Dot Extender

This is a class extender that can be used to manage constants similar to dictionary. The difference is that the members can be accessed through dot notation. Also, you do not need to add @dataclass(froze=True) decorator to your class. You can also iterate through the members of the class.

Example

Suppose that you are dealing with a list of DataFrame columns that must be standardized throughout the project. You can store these values in a class that is extended by class_to_dot Constants class.

from class_to_dot import Constants
import pandas as pd

class DataColumns(Constants):
    COLUMN_ONE = "column_one"
    COLUMN_TWO = "column_two"
    COLUMN_THREE = "column_three"

df = pd.DataFrame({
        DataColumns.COLUMN_ONE : [1,2,3],
        DataColumns.COLUMN_TWO: [4, 5, 6], 
        DataColumns.COLUMN_THREE: [7, 8, 9], 
    })

for column in list(DataColumns):
    print(df[column].sum())

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

class_to_dot-0.1.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

class_to_dot-0.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file class_to_dot-0.1.0.tar.gz.

File metadata

  • Download URL: class_to_dot-0.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for class_to_dot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4d52cd3f0b0ae4ff70744fa17b42365ba4550cd5e30d4960957c3f3f8cb49792
MD5 b045b7d67648cb272d077a754639fde1
BLAKE2b-256 a4ed1f702e7f3512c52d22d5f5d496fa8982b1a1520b3cb76b7d9fc1abee90ef

See more details on using hashes here.

File details

Details for the file class_to_dot-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: class_to_dot-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for class_to_dot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c6246d4bd7d445dbf11063c8c63e3f2d1cc6aa78e7db7a023a26b2c2422d7e96
MD5 946a390dae53846edc1ea132e8669f3a
BLAKE2b-256 325f31b0a9033271b46a9c141dd88ea15d43fda31c67568a43fec61b12c0308e

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