Skip to main content

StrEnum

StrEnum is a Python enum.Enum that inherits from str to complement enum.IntEnum in the standard library. Supports python 3.6+.

Installation

You can use pip to install.

pip install StrEnum

Usage

from enum import auto
from strenum import StrEnum


class HttpMethod(StrEnum):
    GET = auto()
    HEAD = auto()
    POST = auto()
    PUT = auto()
    DELETE = auto()
    CONNECT = auto()
    OPTIONS = auto()
    TRACE = auto()
    PATCH = auto()


print(f"An HTTP method: {HttpMethod.GET}")  # prints "An HTTP method: GET"

Why not enum34-custom's StrEnum?

Because it's not compatible with modern versions of python (see issue).

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please ensure tests pass before submitting a PR. This repository uses Black and Pylint for consistency. Both are run automatically as part of the test suite.

Running the tests

Tests can be run using make:

make test

This will create a virutal environment, install the module and its test dependencies and run the tests. Alternatively you can do the same thing manually:

python3 -m venv .venv
.venv/bin/pip install .[test]
.venv/bin/pytest

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

StrEnum-0.4.1.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

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

StrEnum-0.4.1-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file StrEnum-0.4.1.tar.gz.

File metadata

  • Download URL: StrEnum-0.4.1.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.5

File hashes

Hashes for StrEnum-0.4.1.tar.gz
Algorithm Hash digest
SHA256 b095d093b8ff354f334882f22be73646acef80663051752a0aa3d6f9d6508ef2
MD5 4f9e6d7e827eef540ef01f88c821eb39
BLAKE2b-256 eb16e9d4f2219eab816782dc892453f38d7add362d38fbc22c55045fce649a47

See more details on using hashes here.

File details

Details for the file StrEnum-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: StrEnum-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.5

File hashes

Hashes for StrEnum-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2f38b95cb6465609f65885d7ebbc5ad449d0cf1373a3f517c2da58964f4327ba
MD5 38a149994f8e575b74178471aee5cb16
BLAKE2b-256 eb52f7b516392bd24aec34b9389f9a1cf58c1369e8c961f1d7fb8f1c40ec15e9

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