Skip to content
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

dynamically map Python str flags to C enum flags #5

Open
avg-I opened this issue Aug 6, 2015 · 0 comments
Open

dynamically map Python str flags to C enum flags #5

avg-I opened this issue Aug 6, 2015 · 0 comments

Comments

@avg-I
Copy link
Contributor

avg-I commented Aug 6, 2015

Rather than doing this:

for flag in flags:
    c_flag = {
        'embedded_data':    _lib.LZC_SEND_FLAG_EMBED_DATA,
        'large_blocks':     _lib.LZC_SEND_FLAG_LARGE_BLOCK,
    }.get(flag)
    ...

we can algorithmically map the original strings to string corresponding to enum names in the C code and then use getattr(_lib, ...) to obtain actual values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant