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

Use print() function in both Python 2 and Python 3 #722

Merged
merged 3 commits into from Jul 22, 2019

Conversation

@cclauss
Copy link
Contributor

commented Jul 21, 2019

Legacy print statements are syntax errors in Python 3 but print() function works as expected in both Python 2 and Python 3. Also fixed some undefined names.

Four undefined names remain...

$ flake8 . --count --show-source --statistics --select=E9,F63,F7,F82

./samples/coordinate/coordinate.py:60:13: F821 undefined name 'build'
  service = build('coordinate', 'v1', http=http)
            ^
./samples/coordinate/coordinate.py:60:44: F821 undefined name 'http'
  service = build('coordinate', 'v1', http=http)
                                           ^
./samples/coordinate/coordinate.py:64:46: F821 undefined name 'FLAGS'
    jobs_result = service.jobs().list(teamId=FLAGS.teamId).execute(http=http)
                                             ^
./samples/coordinate/coordinate.py:64:73: F821 undefined name 'http'
    jobs_result = service.jobs().list(teamId=FLAGS.teamId).execute(http=http)
                                                                        ^
4     F821 undefined name 'build'
4
cclauss added 2 commits Jul 21, 2019
Use print() function in both Python 2 and Python 3
Legacy __print__ statements are syntax errors in Python 3 but __print()__ function works as expected in both Python 2 and Python 3.

@googlebot googlebot added the cla: yes label Jul 21, 2019

@busunkim96
Copy link
Contributor

left a comment

Thank you @cclauss!

@busunkim96 busunkim96 merged commit 9fdc2b2 into googleapis:master Jul 22, 2019

1 check passed

cla/google All necessary CLAs are signed

@cclauss cclauss deleted the cclauss:modernize-Python-2-codes branch Jul 22, 2019

@@ -156,7 +156,7 @@ def _retry_request(http, num_retries, req_type, sleep, rand, uri, method, *args,
LOGGER.warning(
'Sleeping %.2f seconds before retry %d of %d for %s: %s %s, after %s',
sleep_time, retry_num, num_retries, req_type, method, uri,
resp.status if resp else exception)
resp.status if resp else Exception)

This comment has been minimized.

Copy link
@tseaver

tseaver Jul 22, 2019

Collaborator

This change loses the re-bound exception below, which means it loses information about the actual cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.