-
Notifications
You must be signed in to change notification settings - Fork 45
IsoCode639_1, IsoCode639_3 Enums don't support Python access by name #254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I know about this problem and I've already fixed it in the Rust implementation. It just has not been released yet. See #225. But I plan to do so this month. In release 2.1.0, the following will work: assert Language.from_str("english") == Language.ENGLISH
assert IsoCode639_1.from_str("en") == IsoCode639_1.EN
assert IsoCode639_3.from_str("eng") == IsoCode639_3.ENG |
It would be nice to also implement It's quite confusing then you see that these are declared as subclasses of Python |
Cool, I did not know that one can implement the behavior of Python enums manually. I will gladly do so then. Thanks for the hint. :) |
As a workaround until that lands, I discovered that you can do this:
|
It turns out that it is currently not possible to implement |
A real Python Enum allows you to do this:
but, perhaps because they're not real Python Enums but rather Rust bindings, the Enums in lingua don't allow this:
If the languages your app supports are (variable) strings, this makes mapping them to lingua enums very annoying.
The text was updated successfully, but these errors were encountered: