-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Use print() function in both Python 2 and Python 3 #2234
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
Use print() function in both Python 2 and Python 3 #2234
Conversation
Legacy __print__ statements are syntax errors in Python 3 but __print()__ function works as expected in both Python 2 and Python 3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM, I think you can get by without the print future and it's preferred to use single-quote strings / string formatter.
@@ -49,15 +54,15 @@ def _get_plural_forms(js_translations): | |||
for l in js_translations._catalog[''].split('\n'): | |||
if l.startswith('Plural-Forms:'): | |||
plural = l.split(':', 1)[1].strip() | |||
print "plural is %s" % plural | |||
print("plural is %s" % plural) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer string formatter and single quotes:
print(`plural is {}`.format(plural))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python/black (think gofmt for Python) is reformatting code to prefer " over ' but I will make the requested change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll consider this alternative style; I don't personally have a strong opinion either way. Thank you for the pointers, also thanks a ton for the fixes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding python/black and quotes, according to the style guide it looks like some teams are using yapf.
@cclauss Friendly ping, happy to accept your enhancements once you've applied the style we prefer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Legacy print statements are syntax errors in Python 3 but print() function works as expected in both Python 2 and Python 3.