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 Python 3

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