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

[MRG] Allow the use of "if" in the shorthand generator syntax #873

Merged
merged 1 commit into from Aug 31, 2017

Conversation

Projects
None yet
2 participants
@mstimberg
Member

mstimberg commented Aug 30, 2017

I noticed this a while ago but never got around fixing it.
At the moment, the short-hand generator syntax (for single targets per source) does not work with if, because something like connect(j='i if i % 2 == 0') is translated into i if i % 2 == 0 for _ in range(1).
My commit is a bit of a quick fix, I think we should probably include the parsing of the short-hand code into the parse_generator_syntax function in the long run to make the code easier to follow.

Either way, I'd be happy if this could be merged as a short-term solution, I have a use case for this and writing for _ in range(1) is really ugly...

@thesamovar

Seems reasonable to me!

@mstimberg mstimberg merged commit 109ed5b into master Aug 31, 2017

4 checks passed

continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@mstimberg mstimberg deleted the fix_if_in_short_generator_connect branch Aug 31, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment