-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Iterate over enums #253
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
Are you proposing to implement such a feature? A PR with a custom |
A side thought, would it make sense to consider using standard library's https://docs.python.org/3/library/enum.html -- |
It sounds tricky -- |
@wjakob I will try. Actually I use this trick: import re
def enum_to_dict(enum):
return {k: v for k, v in enum.__dict__.iteritems() if not re.match("__(.*)__", str(k))} |
I'll close this ticket since there isn't an issue with pybind11 -- if you'd like to contribute this as a feature, please open a pull request. Thanks, |
Actually we can't iterate over a enum. It could be nice to enable this kind of code:
The text was updated successfully, but these errors were encountered: