Skip to main content

Python library for managing string types

Project description

Str Types

Python library for managing string types

pip install strtypes


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')


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 == "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.

Files for strtypes, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size strtypes-0.0.2-py3-none-any.whl (3.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size strtypes-0.0.2.tar.gz (2.1 kB) File type Source Python version None Upload date Hashes View

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 Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page