Skip to content

Comments

Don't add from __future__ import print_function in generated file#3

Open
santazhang wants to merge 2 commits intosmurfix:masterfrom
santazhang:patch-1
Open

Don't add from __future__ import print_function in generated file#3
santazhang wants to merge 2 commits intosmurfix:masterfrom
santazhang:patch-1

Conversation

@santazhang
Copy link

from __future__ import print_function must be placed at beginning of python file. But the user might have a header code section specified in .g file (before %% marker), and in this case the generated parser will not work. I think it's better to let users add from __future__ import print_function themselves.

`from __future__ import print_function` must be placed at beginning of python file. But the user might have a header code section specified in .g file (before %% marker), and in this case the generated parser will not work. I think it's better to let users add `from __future__ import print_function` themselves.
Users might or might not add `from __future__ import print_function`.
Generated code should work in either case.
@felixp7
Copy link

felixp7 commented Sep 23, 2015

I just ran into the same issue, and worked around it by editing the generated parser. The simpler solution is to insert the pre-parse code from the grammar file after the import statements, rather than before. Nothing else needs to be changed.

@jepler
Copy link

jepler commented Mar 7, 2018

#6 resolves this in a way that still allows the from __future__ import print_function to be in the generated file, similar to what @felixplesoianu described doing manually.

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

Successfully merging this pull request may close these issues.

3 participants