-
Notifications
You must be signed in to change notification settings - Fork 748
Get Value Of An Enum #1585
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
This is possible using codecs, though they are /really/ unergonomic so far when using them from Python:
The decoder is buggy right now (fix in #1621). @lostmsu Do you have a proposal for a nice ergonomic Python API for this? Should we enable some encoders/decoders by default unless told otherwise? |
I don't think enabling codecs by default is a good idea, unless they are 1:1 exact rountrippable mappings. As for the more ergonomic Python APIs, somebody more proficient with Python should propose those. |
As for the issue at hand, .NET enums should implement |
Isn't that something that we explicitly removed? |
If I remember correctly, we removed the code, that converted any enum value to an integer implicitly when passed to Python. You could never previously get raw enum value in Python, it always just saw integers. So the corresponding type never had |
So if I understand you correctly, we all agree that adding a default I would have implemented this ability myself, but I have zero knowledge in C#. Let me know if I can help you somehow make this ability happen. |
…num.Member) implements pythonnet#1585
…num.Member) implements pythonnet#1585
…num.Member) implements pythonnet#1585
…num.Member) implements pythonnet#1585
…num.Member) implements pythonnet#1585
Environment
Details
I would like to have the ability to extract the value of a .Net
Enum
via python. One can do that usingMyEnum.value__
, however it seems logical that you should do it usingint(MyEnum)
.Minimal, Complete, and Verifiable example
this will help us understand the issue.
That prints:
No crash.
The text was updated successfully, but these errors were encountered: