Skip to content

Commit 0b054ee

Browse files
lukaselmerdkropachev
authored andcommitted
docs: convert print statement to function in docs (datastax#1157)
1 parent b4f4354 commit 0b054ee

File tree

11 files changed

+35
-35
lines changed

11 files changed

+35
-35
lines changed

cassandra/cluster.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ def default_retry_policy(self, policy):
10141014
cloud = None
10151015
"""
10161016
A dict of the cloud configuration. Example::
1017-
1017+
10181018
{
10191019
# path to the secure connect bundle
10201020
'secure_connect_bundle': '/path/to/secure-connect-dbname.zip',
@@ -1542,7 +1542,7 @@ def __init__(self, street, zipcode):
15421542
# results will include Address instances
15431543
results = session.execute("SELECT * FROM users")
15441544
row = results[0]
1545-
print row.id, row.location.street, row.location.zipcode
1545+
print(row.id, row.location.street, row.location.zipcode)
15461546
15471547
"""
15481548
if self.protocol_version < 3:

cassandra/cqlengine/query.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,15 +285,15 @@ class ContextQuery(object):
285285
286286
with ContextQuery(Automobile, keyspace='test2') as A:
287287
A.objects.create(manufacturer='honda', year=2008, model='civic')
288-
print len(A.objects.all()) # 1 result
288+
print(len(A.objects.all())) # 1 result
289289
290290
with ContextQuery(Automobile, keyspace='test4') as A:
291-
print len(A.objects.all()) # 0 result
291+
print(len(A.objects.all())) # 0 result
292292
293293
# Multiple models
294294
with ContextQuery(Automobile, Automobile2, connection='cluster2') as (A, A2):
295-
print len(A.objects.all())
296-
print len(A2.objects.all())
295+
print(len(A.objects.all()))
296+
print(len(A2.objects.all()))
297297
298298
"""
299299

@@ -808,11 +808,11 @@ class Comment(Model):
808808
809809
print("Normal")
810810
for comment in Comment.objects(photo_id=u):
811-
print comment.comment_id
811+
print(comment.comment_id)
812812
813813
print("Reversed")
814814
for comment in Comment.objects(photo_id=u).order_by("-comment_id"):
815-
print comment.comment_id
815+
print(comment.comment_id)
816816
"""
817817
if len(colnames) == 0:
818818
clone = copy.deepcopy(self)

cassandra/datastax/graph/fluent/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def traversal_source(session=None, graph_name=None, execution_profile=EXEC_PROFI
257257
session = c.connect()
258258
259259
g = DseGraph.traversal_source(session, 'my_graph')
260-
print g.V().valueMap().toList()
260+
print(g.V().valueMap().toList())
261261
262262
"""
263263

cassandra/query.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def tuple_factory(colnames, rows):
7575
>>> session = cluster.connect('mykeyspace')
7676
>>> session.row_factory = tuple_factory
7777
>>> rows = session.execute("SELECT name, age FROM users LIMIT 1")
78-
>>> print rows[0]
78+
>>> print(rows[0])
7979
('Bob', 42)
8080
8181
.. versionchanged:: 2.0.0
@@ -131,16 +131,16 @@ def named_tuple_factory(colnames, rows):
131131
>>> user = rows[0]
132132
133133
>>> # you can access field by their name:
134-
>>> print "name: %s, age: %d" % (user.name, user.age)
134+
>>> print("name: %s, age: %d" % (user.name, user.age))
135135
name: Bob, age: 42
136136
137137
>>> # or you can access fields by their position (like a tuple)
138138
>>> name, age = user
139-
>>> print "name: %s, age: %d" % (name, age)
139+
>>> print("name: %s, age: %d" % (name, age))
140140
name: Bob, age: 42
141141
>>> name = user[0]
142142
>>> age = user[1]
143-
>>> print "name: %s, age: %d" % (name, age)
143+
>>> print("name: %s, age: %d" % (name, age))
144144
name: Bob, age: 42
145145
146146
.. versionchanged:: 2.0.0
@@ -186,7 +186,7 @@ def dict_factory(colnames, rows):
186186
>>> session = cluster.connect('mykeyspace')
187187
>>> session.row_factory = dict_factory
188188
>>> rows = session.execute("SELECT name, age FROM users LIMIT 1")
189-
>>> print rows[0]
189+
>>> print(rows[0])
190190
{u'age': 42, u'name': u'Bob'}
191191
192192
.. versionchanged:: 2.0.0

docs/api/cassandra/cqlengine/models.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Model
103103
TestIfNotExistsModel.if_not_exists().create(id=id, count=9, text='111111111111')
104104
except LWTException as e:
105105
# handle failure case
106-
print e.existing # dict containing LWT result fields
106+
print(e.existing) # dict containing LWT result fields)
107107
108108
This method is supported on Cassandra 2.0 or later.
109109

@@ -144,7 +144,7 @@ Model
144144
t.iff(count=5).update('other text')
145145
except LWTException as e:
146146
# handle failure case
147-
print e.existing # existing object
147+
print(e.existing) # existing object
148148
149149
.. automethod:: get
150150

docs/cqlengine/connections.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ You can specify a default connection per model:
9999
year = columns.Integer(primary_key=True)
100100
model = columns.Text(primary_key=True)
101101
102-
print len(Automobile.objects.all()) # executed on the connection 'cluster2'
102+
print(len(Automobile.objects.all())) # executed on the connection 'cluster2'
103103
104104
QuerySet and model instance
105105
---------------------------

docs/cqlengine/models.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ are only created, presisted, and queried via table Models. A short example to in
201201

202202
users.create(name="Joe", addr=address(street="Easy St.", zipcode=99999))
203203
user = users.objects(name="Joe")[0]
204-
print user.name, user.addr
204+
print(user.name, user.addr)
205205
# Joe address(street=u'Easy St.', zipcode=99999)
206206

207207
UDTs are modeled by inheriting :class:`~.usertype.UserType`, and setting column type attributes. Types are then used in defining

docs/execution-profiles.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Default
4343
session = cluster.connect()
4444
local_query = 'SELECT rpc_address FROM system.local'
4545
for _ in cluster.metadata.all_hosts():
46-
print session.execute(local_query)[0]
46+
print(session.execute(local_query)[0])
4747
4848
4949
.. parsed-literal::
@@ -69,7 +69,7 @@ Initializing cluster with profiles
6969
profiles = {'node1': node1_profile, 'node2': node2_profile}
7070
session = Cluster(execution_profiles=profiles).connect()
7171
for _ in cluster.metadata.all_hosts():
72-
print session.execute(local_query, execution_profile='node1')[0]
72+
print(session.execute(local_query, execution_profile='node1')[0])
7373
7474
7575
.. parsed-literal::
@@ -81,7 +81,7 @@ Initializing cluster with profiles
8181
.. code:: python
8282
8383
for _ in cluster.metadata.all_hosts():
84-
print session.execute(local_query, execution_profile='node2')[0]
84+
print(session.execute(local_query, execution_profile='node2')[0])
8585
8686
8787
.. parsed-literal::
@@ -93,7 +93,7 @@ Initializing cluster with profiles
9393
.. code:: python
9494
9595
for _ in cluster.metadata.all_hosts():
96-
print session.execute(local_query)[0]
96+
print(session.execute(local_query)[0])
9797
9898
9999
.. parsed-literal::
@@ -123,7 +123,7 @@ New profiles can be added constructing from scratch, or deriving from default:
123123
cluster.add_execution_profile(node1_profile, locked_execution)
124124
125125
for _ in cluster.metadata.all_hosts():
126-
print session.execute(local_query, execution_profile=node1_profile)[0]
126+
print(session.execute(local_query, execution_profile=node1_profile)[0])
127127
128128
129129
.. parsed-literal::
@@ -144,8 +144,8 @@ We also have the ability to pass profile instances to be used for execution, but
144144
145145
tmp = session.execution_profile_clone_update('node1', request_timeout=100, row_factory=tuple_factory)
146146
147-
print session.execute(local_query, execution_profile=tmp)[0]
148-
print session.execute(local_query, execution_profile='node1')[0]
147+
print(session.execute(local_query, execution_profile=tmp)[0])
148+
print(session.execute(local_query, execution_profile='node1')[0])
149149
150150
.. parsed-literal::
151151

docs/faq.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Since tracing is done asynchronously to the request, this method polls until the
4444
>>> result = future.result()
4545
>>> trace = future.get_query_trace()
4646
>>> for e in trace.events:
47-
>>> print e.source_elapsed, e.description
47+
>>> print(e.source_elapsed, e.description)
4848
4949
0:00:00.000077 Parsing select * from system.local
5050
0:00:00.000153 Preparing statement
@@ -67,7 +67,7 @@ With prepared statements, the replicas are obtained by ``routing_key``, based on
6767
>>> bound = prepared.bind((1,))
6868
>>> replicas = cluster.metadata.get_replicas(bound.keyspace, bound.routing_key)
6969
>>> for h in replicas:
70-
>>> print h.address
70+
>>> print(h.address)
7171
127.0.0.1
7272
127.0.0.2
7373

docs/getting-started.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ way to execute a query is to use :meth:`~.Session.execute()`:
119119
120120
rows = session.execute('SELECT name, age, email FROM users')
121121
for user_row in rows:
122-
print user_row.name, user_row.age, user_row.email
122+
print(user_row.name, user_row.age, user_row.email)
123123
124124
This will transparently pick a Cassandra node to execute the query against
125125
and handle any retries that are necessary if the operation fails.
@@ -135,19 +135,19 @@ examples are equivalent:
135135
136136
rows = session.execute('SELECT name, age, email FROM users')
137137
for row in rows:
138-
print row.name, row.age, row.email
138+
print(row.name, row.age, row.email)
139139
140140
.. code-block:: python
141141
142142
rows = session.execute('SELECT name, age, email FROM users')
143143
for (name, age, email) in rows:
144-
print name, age, email
144+
print(name, age, email)
145145
146146
.. code-block:: python
147147
148148
rows = session.execute('SELECT name, age, email FROM users')
149149
for row in rows:
150-
print row[0], row[1], row[2]
150+
print(row[0], row[1], row[2])
151151
152152
If you prefer another result format, such as a ``dict`` per row, you
153153
can change the :attr:`~.Session.row_factory` attribute.
@@ -335,7 +335,7 @@ For example:
335335
try:
336336
rows = future.result()
337337
user = rows[0]
338-
print user.name, user.age
338+
print(user.name, user.age)
339339
except ReadTimeout:
340340
log.exception("Query timed out:")
341341
@@ -352,7 +352,7 @@ This works well for executing many queries concurrently:
352352
# wait for them to complete and use the results
353353
for future in futures:
354354
rows = future.result()
355-
print rows[0].name
355+
print(rows[0].name)
356356
357357
Alternatively, instead of calling :meth:`~.ResponseFuture.result()`,
358358
you can attach callback and errback functions through the

0 commit comments

Comments
 (0)