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

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

Merged
merged 1 commit into from Aug 31, 2017

Conversation

mstimberg
Copy link
Member

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...

Copy link
Member

@thesamovar thesamovar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me!

@mstimberg mstimberg merged commit 109ed5b into master Aug 31, 2017
@mstimberg mstimberg deleted the fix_if_in_short_generator_connect branch August 31, 2017 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants