On 04/25/2013 10:01 PM, Steven D'Aprano wrote:
> On 26/04/13 13:22, Greg wrote:
>> On 26/04/2013 3:12 p.m., Glenn Linderman wrote:
>>> On 4/25/2013 7:49 PM, Nick Coghlan wrote:
>>>>>> You couldn't create an enum of callables, but that would be a
>>>> seriously weird thing to do anyway....
>>>>>> But aren't all classes callable?
>>>> An enum of classes would be seriously weird as well, I think.
>>> I don't think iscallable will work, since that descriptors like
> staticmethod and classmethod aren't callable. Nor are properties.
>>> I think a solution may be an explicit decorator that tells the
> metaclass not to skip the object into an enum value:
Another option is to check if the item is a descriptor (class, static, property, or other); yet another option is to
check if the item is the type of the enum class (int for IntEnum, str for StrEnum, etc.).
The code I posted earlier checks for callable and type -- checking for descriptor also would not be much more effort.
--
~Ethan~