[issue38375] Enum lookup fails for callable values

2019-10-07 Thread Massimo


Massimo  added the comment:

Where is this documented? Sorry, I couldn't find it.

In any case, I'd say this behaviour is quite unexpected, and unless technical 
reasons are overwhelming, would be nice to change it.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38375] Enum lookup fails for callable values

2019-10-07 Thread Ethan Furman


Ethan Furman  added the comment:

This is the intended, and documented, behavior.

--
assignee:  -> ethan.furman
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38375] Enum lookup fails for callable values

2019-10-05 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Some relevant threads

* 
https://stackoverflow.com/questions/40338652/how-to-define-enum-values-that-are-functions
* https://mail.python.org/pipermail/python-ideas/2017-April/045428.html

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38375] Enum lookup fails for callable values

2019-10-05 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

https://docs.python.org/3/library/enum.html#allowed-members-and-attributes-of-enumerations

> The rules for what is allowed are as follows: names that start and end with a 
> single underscore are reserved by enum and cannot be used; all other 
> attributes defined within an enumeration will become members of this 
> enumeration, with the exception of special methods (__str__(), __add__(), 
> etc.), descriptors (methods are also descriptors), and variable names listed 
> in _ignore_.

Looking at the code _member_names has the list of member names internally that 
stores the members. I guess with a callable assigned to TEST it becomes a 
method and is not added as a member as per the above doc to skip descriptor as 
method.

--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38375] Enum lookup fails for callable values

2019-10-05 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +ethan.furman

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38375] Enum lookup fails for callable values

2019-10-05 Thread Massimo


New submission from Massimo :

```
from enum import Enum

class T(Enum):
  TEST = 1

print(T["TEST"])

class S(Enum):
  TEST = lambda a: a

print(S["TEST"])
```
fails with `KeyError: 'TEST'` on the last line.

--
components: Interpreter Core
messages: 354003
nosy: typish
priority: normal
severity: normal
status: open
title: Enum lookup fails for callable values
type: behavior
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com