Skip to content

Commit 5e3a35e

Browse files
authored
Merge pull request #2424 from dhermes/py3-friendly-print
Making prints Python 3 friendly.
2 parents eec16d0 + 0e62998 commit 5e3a35e

File tree

9 files changed

+21
-21
lines changed

9 files changed

+21
-21
lines changed

README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ to activate Cloud Datastore for your project.
101101
# Then query for entities
102102
query = datastore.Query(kind='EntityKind')
103103
for result in query.fetch():
104-
print result
104+
print(result)
105105
106106
Google Cloud Storage
107107
--------------------
@@ -131,7 +131,7 @@ how to create a bucket.
131131
bucket = client.get_bucket('bucket-id-here')
132132
# Then do other things...
133133
blob = bucket.get_blob('remote/path/to/file.txt')
134-
print blob.download_as_string()
134+
print(blob.download_as_string())
135135
blob.upload_from_string('New contents!')
136136
blob2 = bucket.blob('remote/path/storage.txt')
137137
blob2.upload_from_filename(filename='/local/path.txt')
@@ -220,7 +220,7 @@ Perform a synchronous query
220220
query.run()
221221
222222
for row in query.rows:
223-
print row
223+
print(row)
224224
225225
226226
See the ``google-cloud-python`` API `BigQuery documentation`_ to learn how to connect
@@ -265,7 +265,7 @@ Example of fetching entries:
265265
266266
entries, token = logger.list_entries()
267267
for entry in entries:
268-
print entry.payload
268+
print(entry.payload)
269269
270270
See the ``google-cloud-python`` API `logging documentation`_ to learn how to connect
271271
to Stackdriver Logging using this Client Library.

core/google/cloud/iterator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def get_items_from_response(self, response):
3939
requests)::
4040
4141
>>> for item in MyIterator(...):
42-
>>> print item.name
42+
>>> print(item.name)
4343
>>> if not item.is_valid:
4444
>>> break
4545
"""

google/cloud/monitoring/group.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,21 +279,21 @@ def list_members(self, filter_string=None, end_time=None, start_time=None):
279279
Example::
280280
281281
>>> for member in group.list_members():
282-
... print member
282+
... print(member)
283283
284284
List members that are Compute Engine VM instances::
285285
286286
>>> filter_string = 'resource.type = "gce_instance"'
287287
>>> for member in group.list_members(filter_string=filter_string):
288-
... print member
288+
... print(member)
289289
290290
List historical members that existed between 4 and 5 hours ago::
291291
292292
>>> import datetime
293293
>>> t1 = datetime.datetime.utcnow() - datetime.timedelta(hours=4)
294294
>>> t0 = t1 - datetime.timedelta(hours=1)
295295
>>> for member in group.list_members(end_time=t1, start_time=t0):
296-
... print member
296+
... print(member)
297297
298298
299299
:type filter_string: string or None

google/cloud/resource_manager/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def list_projects(self, filter_params=None, page_size=None):
104104
>>> from google.cloud import resource_manager
105105
>>> client = resource_manager.Client()
106106
>>> for project in client.list_projects():
107-
... print project.project_id
107+
... print(project.project_id)
108108
109109
List all projects with label ``'environment'`` set to ``'prod'``
110110
(filtering by labels)::
@@ -113,7 +113,7 @@ def list_projects(self, filter_params=None, page_size=None):
113113
>>> client = resource_manager.Client()
114114
>>> env_filter = {'labels.environment': 'prod'}
115115
>>> for project in client.list_projects(env_filter):
116-
... print project.project_id
116+
... print(project.project_id)
117117
118118
See:
119119
https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects/list

scripts/generate_json_docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ def main():
651651
os.path.join(JSON_DOCS_DIR, 'types.json'))
652652
package_files(JSON_DOCS_DIR, DOCS_BUILD_DIR, BASE_JSON_DOCS_DIR)
653653
if args.show_toc:
654-
print json.dumps(toc, indent=4)
654+
print(json.dumps(toc, indent=4))
655655

656656
if __name__ == '__main__':
657657
main()

storage/google/cloud/storage/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
>>> bucket = client.get_bucket('bucket-id-here')
2222
>>> # Then do other things...
2323
>>> blob = bucket.get_blob('/remote/path/to/file.txt')
24-
>>> print blob.download_as_string()
24+
>>> print(blob.download_as_string())
2525
>>> blob.upload_from_string('New contents!')
2626
>>> blob2 = bucket.blob('/remote/path/storage.txt')
2727
>>> blob2.upload_from_filename(filename='/local/path.txt')

storage/google/cloud/storage/acl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
To get the list of ``entity`` and ``role`` for each unique pair, the
7272
:class:`ACL` class is iterable::
7373
74-
>>> print list(ACL)
74+
>>> print(list(ACL))
7575
[{'role': 'OWNER', 'entity': 'allUsers'}, ...]
7676
7777
This list of tuples can be used as the ``entity`` and ``role`` fields

storage/google/cloud/storage/bucket.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ def get_blob(self, blob_name, client=None):
211211
>>> from google.cloud import storage
212212
>>> client = storage.Client()
213213
>>> bucket = client.get_bucket('my-bucket')
214-
>>> print bucket.get_blob('/path/to/blob.txt')
214+
>>> print(bucket.get_blob('/path/to/blob.txt'))
215215
<Blob: my-bucket, /path/to/blob.txt>
216-
>>> print bucket.get_blob('/does-not-exist.txt')
216+
>>> print(bucket.get_blob('/does-not-exist.txt'))
217217
None
218218
219219
:type blob_name: string
@@ -376,7 +376,7 @@ def delete_blob(self, blob_name, client=None):
376376
>>> from google.cloud import storage
377377
>>> client = storage.Client()
378378
>>> bucket = client.get_bucket('my-bucket')
379-
>>> print bucket.list_blobs()
379+
>>> print(bucket.list_blobs())
380380
[<Blob: my-bucket, my-file.txt>]
381381
>>> bucket.delete_blob('my-file.txt')
382382
>>> try:

storage/google/cloud/storage/client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def get_bucket(self, bucket_name):
152152
>>> try:
153153
>>> bucket = client.get_bucket('my-bucket')
154154
>>> except google.cloud.exceptions.NotFound:
155-
>>> print 'Sorry, that bucket does not exist!'
155+
>>> print('Sorry, that bucket does not exist!')
156156
157157
This implements "storage.buckets.get".
158158
@@ -174,10 +174,10 @@ def lookup_bucket(self, bucket_name):
174174
than catching an exception::
175175
176176
>>> bucket = client.lookup_bucket('doesnt-exist')
177-
>>> print bucket
177+
>>> print(bucket)
178178
None
179179
>>> bucket = client.lookup_bucket('my-bucket')
180-
>>> print bucket
180+
>>> print(bucket)
181181
<Bucket: my-bucket>
182182
183183
:type bucket_name: string
@@ -197,7 +197,7 @@ def create_bucket(self, bucket_name):
197197
For example::
198198
199199
>>> bucket = client.create_bucket('my-bucket')
200-
>>> print bucket
200+
>>> print(bucket)
201201
<Bucket: my-bucket>
202202
203203
This implements "storage.buckets.insert".
@@ -223,7 +223,7 @@ def list_buckets(self, max_results=None, page_token=None, prefix=None,
223223
bucket.
224224
225225
>>> for bucket in client.list_buckets():
226-
>>> print bucket
226+
... print(bucket)
227227
228228
This implements "storage.buckets.list".
229229

0 commit comments

Comments
 (0)