Profile

Cover photo
christopher ede
31,248 views
AboutPostsPhotosVideos

Stream

 
it is probably me but the dict-interface of the python enum-class strikes me extremely odd consider the following test-code:

==================================
enum_question$ cat enum_test.py 
# file: enum_test
from _future_ import print_function
import enum

class Foo(enum.Enum):
    BAR = 1
    BAZ = 1

print('get BAR:', Foo['BAR'])
print('get BAZ:', Foo['BAZ'])
==================================

guess what, one finds on the terminal:

==================================
enum_question$ python3 enum_test.py 
get BAR: Foo.BAR
get BAZ: Foo.BAR
==================================

in plain english: ask for 'BAZ' and you shall be given 'BAR' !! :-o

OK, they have the same value, but still; it is kind of unexpected; again at least if you think like me; 
3
1
christopher ede's profile photoAndreas Kostyrka's profile photoEvaldo Araújo's profile photo
3 comments
 
+christopher ede​ that's not what an enum is, at least in all languages that I know. Is always about coding symbols with integers. And that obviously means that there can be only one inverse mapping.
Add a comment...

christopher ede

Discussion  - 
 
interesting opinion piece from NY-times
Alfalfa, grown for Asian cattle, is worsening California’s drought.
3
2
Richard Schwarting's profile photochristopher ede's profile photoVegalicious's profile photoNikki Emmerton's profile photo
2 comments
 
+Richard Schwarting
thanks i did not know this site makes for an interesting read
Add a comment...

christopher ede

Einsteiger/Allgemeines  - 
 
in kalifornien ist derzeit eine der schlimmsten duerren seit beginn der aufzeichnungen was auch zu diskussionen ueber die verwendung von wasser fuehrt, dazu ein kommentar in der NY-times
 ·  Translate
Alfalfa, grown for Asian cattle, is worsening California’s drought.
10
christopher ede's profile photoOliver V  Rani's profile photo
5 comments
 
Ich esse sowieso fleischlos. Und kaufe im Bioladen mein essen ein. Zertifiziert. Ich weiß was ich esse.
 ·  Translate
Add a comment...
Collections christopher is following
Basic Information
Gender
Male