Hacker News new | ask | show | jobs
by quietbritishjim 1534 days ago
Python has had enums [1] since Python 3.4 (2014). You can easily convert back and forth between enum values and their string and numeric values.

I don't know anything about Ruby or Erlang so I don't know if that's really relevant, just your comment seems to imply it doesn't.

[1] https://docs.python.org/3/library/enum.html

2 comments

Yes, that's fair. I suppose I was describing my process of "discovery" and learning with Python which was significantly before 2014. Even now though, enums are not usually the normal way of doing things in public APIs, but that's presumably at least in part because of the history.
Also, unlike Ruby, string literals are usually interned in CPython (I think below a certain size), so they have at least some of the performance benefits of symbols in Ruby.