andreachild commented on code in PR #3231:
URL: https://github.com/apache/tinkerpop/pull/3231#discussion_r2402862052
##########
gremlin-python/src/main/python/examples/basic_gremlin.py:
##########
@@ -47,6 +52,9 @@ def main():
for person in people_marko_knows:
print("marko knows " + person)
+ # clean added data
+ g.V().drop().iterate()
+
Review Comment:
It is a little bit risky to drop all data at the beginning of this example
since it will be running with other tests and examples. We can isolate the data
for this test by using a specialized label (.ie `person-py-ex` instead of
`person`).
```suggestion
# basic Gremlin: adding and retrieving data
v1 = g.add_v('person-py-ex').property('name', 'marko').next()
v2 = g.add_v('person-py-ex').property('name', 'stephen').next()
v3 = g.add_v('person-py-ex').property('name', 'vadas').next()
# be sure to use a terminating step like next() or iterate() so that the
traversal "executes"
# iterate() does not return any data and is used to just generate
side-effects (i.e. write data to the database)
g.V(v1).add_e('knows').to(v2).property('weight', 0.75).iterate()
g.V(v1).add_e('knows').to(v3).property('weight', 0.75).iterate()
# retrieve the data from the "marko" vertex
marko = g.V().has('person-py-ex', 'name', 'marko').values('name').next()
print("name: " + marko)
# find the "marko" vertex and then traverse to the people he "knows" and
return their data
people_marko_knows = g.V().has('person-py-ex', 'name',
'marko').out('knows').values('name').to_list()
for person in people_marko_knows:
print("marko knows " + person)
# clean added data
g.V().has_label('person-py-ex').drop().iterate()
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]