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.2.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.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: StrEnum-0.4.2.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.2.tar.gz
Algorithm Hash digest
SHA256 d85555b4ef8831f3008c0a9298aba629a34edf8f566095a8cb3239559d583394
MD5 a9605aae98cbd3adc21df768bab0acac
BLAKE2b-256 7cf8540b56fdc2b203cb519366dee7a92f3bb49b8989f62a0de2f0f5a42d80e7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: StrEnum-0.4.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4405afd1db8266c8a69c1158d53c22eeca98681ed5259371c27c568eda621e32
MD5 968d280fbb5c834de4b8c8df0f8cb508
BLAKE2b-256 cb0573c4e898ca5d8f4ff519b491816e584911f833b15d16b356aa206eda5cc0

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