Python library for managing string types
Project description
Str Types
Python library for managing string types
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
Release history Release notifications | RSS feed
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.1.tar.gz
(2.0 kB
view hashes)