auto-name-enum-2.0.0
توضیحات
String-based Enum class that automatically assigns values
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | auto-name-enum-2.0.0 |
| نام | auto-name-enum |
| نسخه کتابخانه | 2.0.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Tucker Beck |
| ایمیل نویسنده | tucker.beck@gmail.com |
| آدرس صفحه اصلی | https://github.com/dusktreader/auto-name-enum |
| آدرس اینترنتی | https://pypi.org/project/auto-name-enum/ |
| مجوز | MIT |
# A utility for producing enums with automatic names
This package provides an extension of python Enum objects that automatically
assigns values to members. This uses the `auto()` feature to assign text values
to the enums instead of having to manually set them.
## Specifying your enum
For example, you might create an enum with this like so:
```
class Pets(AutoNameEnum):
DOG = auto()
CAT = auto()
PIG = auto()
```
## Getting values
Using the class, verify the value of `DOG` would be 'dog':
```
>>> print(Pets.DOG.value)
'DOG'
```
You may also get the same value by just using the name of the item:
```
>>> print(Pets.DOG)
'DOG'
```
## Iterating
Python enums may be iterated over:
```
for pet in Pets:
print(f"name: {pet.name}, value: {pet.value}")
```
For more information on enums (and the auto method), see [the official docs]
(https://docs.python.org/3/library/enum.html)
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6.2,<4.0.0 | Python |
نحوه نصب
نصب پکیج whl auto-name-enum-2.0.0:
pip install auto-name-enum-2.0.0.whl
نصب پکیج tar.gz auto-name-enum-2.0.0:
pip install auto-name-enum-2.0.0.tar.gz