'Why in python data types are returned differently based on the way ENUM declared?
from requests import delete, get, post, put
from enum import Enum
class HTTPMethod(Enum):
"""HTTP methods allowed."""
GET = (True,get)
PUT = (False,put)
POST = (True,post)
DELETE = (False,delete)
>> data = HTTPMethod.GET
>> type(data)
Returns : <enum 'HTTPMethod'>
The datatype returned in the above one is enum but When the Enum is declared as mentioned below the data type returned is a function. Any idea why is it this way ??
from requests import delete, get, post, put
from enum import Enum
class HTTPMethod(Enum):
"""HTTP methods allowed."""
GET = get
PUT = put
POST = post
DELETE = delete
>> data = HTTPMethod.GET
>> type(data)
Returns : function
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
