an enum `AutoName` from python docs with multiple stringcase options
Project description
autoname
an enum AutoName from python docs with multiple stringcase options.
Get Started
$ pip install autoname
from autoname import AutoName
from enum import auto
# an enum class
class GameType(AutoName):
INDIE = auto()
print(GameType.INDIE.value) # "INDIE"
# could be alternative in pydantic instead of literal
from pydantic import BaseModel
class Game(BaseModel):
type: GameType
Also have others stringcases coverter
AutoNameLower- convert name value to lowercaseAutoNameUpper- convert name value to uppercase
e.g.
from autoname import AutoNameLower
from enum import auto
class GameType(AutoNameLower):
INDIE = auto()
print(GameType.INDIE.value) # "indie"
You could also bring your own case convertion algorithm.
from autoname import AutoName, transform
from enum import auto
@transform(function=str.lower)
class GameType(AutoName):
INDIE = auto()
print(GameType.INDIE.value) # "indie"
If the autoname is not a sound variable name. there are alias too.
StrEnum=AutoNameLowerStrEnum=AutoNameLowerUpperStrEnum=AutoNameUpper
e.g.
from autoname import StrEnum, transform
from enum import auto
class GameType(StrEnum):
INDIE = auto()
print(GameType.INDIE.value) # "INDIE"
Alternative
StrEnumfromfastapi-utils
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
autoname-2.1.0.tar.gz
(3.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file autoname-2.1.0.tar.gz.
File metadata
- Download URL: autoname-2.1.0.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.1 CPython/3.9.12 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70230d481a6ffede9538b10c046d4cf0111809c07d750f66f4a9655c728c4c4a
|
|
| MD5 |
921fb6c502395bc0bbd330b196160efe
|
|
| BLAKE2b-256 |
802f5263cc73cb71cdfc943a50b2111c4b0fdc941bb090b6183b4234ad447071
|
File details
Details for the file autoname-2.1.0-py3-none-any.whl.
File metadata
- Download URL: autoname-2.1.0-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.1 CPython/3.9.12 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab889c62c94062c32e926ab582464fb913714262723be8d758ffba05a1994d23
|
|
| MD5 |
b81a8f114adf320bd9b56c8a20dc023e
|
|
| BLAKE2b-256 |
d1ce27bb0986553cf3e241f6543f580e359707937706d4d46b9e7b784ae45e57
|