Message270107
| Author |
ethan.furman |
| Recipients |
John Hagen, barry, eli.bendersky, ethan.furman |
| Date |
2016年07月10日.17:42:18 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1468172538.35.0.576778185899.issue26988@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I like AutoEnum.
Another auto-related thought: one of the more common Enum questions on StackOverflow is how to automatically have the value be the stringified version of the name:
class Huh(Enum):
this
that
those
Huh.this.name == Huh.this.value
# True
So the question then becomes: is there a way to easily support both auto-number and auto-string values?
While I don't have the auto-string feature yet in aenum, the system I am using to specify optional settings looks like this:
------
class Color(Enum, settings=AutoNumber):
red
...
------
------
class Color(IntEnum, settings=AutoNumber):
red
...
------
------
class Color(Enum, settings=AutoName):
red
...
------
The other option, of course, is to just stick with the prebuilt method of doing things:
class Color(AutoEnum):
...
class Color(AutoEnum, IntEnum):
...
class Color(AutoNameEnum):
... |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2016年07月10日 17:42:18 | ethan.furman | set | recipients:
+ ethan.furman, barry, eli.bendersky, John Hagen |
| 2016年07月10日 17:42:18 | ethan.furman | set | messageid: <1468172538.35.0.576778185899.issue26988@psf.upfronthosting.co.za> |
| 2016年07月10日 17:42:18 | ethan.furman | link | issue26988 messages |
| 2016年07月10日 17:42:18 | ethan.furman | create |
|