Skip to main content

Python library for managing string types

Project description

Str Types

Python library for managing string types

pip install strtypes

Links

Quick Overview

Define a class that inherits from StrTyped, then define any number of StrType objects, like this:

from strtypes import StrTyped, StrType

class StatusTypes(StrTyped):
    active = StrType('active')
    hold = StrType('hold')

Example

from strtypes import DjangoStrTyped, StrType

class QTypes(DjangoStrTyped):
    radio = StrType("radio", "one from list")
    checkbox = StrType("checkbox", "many from list")
    user_input = StrType("user_input", "user input")
    not_an_strtype = "..."

Here is what you got:

assert QTypes.radio == "radio"
assert "user_input" == QTypes.user_input
assert str(QTypes.checkbox) == "checkbox"
assert len(QTypes.all_strtypes()) == 3
assert len(QTypes.choices_style()) == 3
assert QTypes.choices_style()[0] == ("radio", "one from list")

You may notice that this package comes with DjangoStrTyped which has some special methods for django development.

More examples in examples/ directory

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

strtypes-0.0.2.tar.gz (2.1 kB view hashes)

Uploaded source

Built Distribution

strtypes-0.0.2-py3-none-any.whl (3.0 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page