Gremlinpython: NameError: name 'otherV' is not defined

658 views
Skip to first unread message

ken.gri...@gmail.com

unread,
May 15, 2018, 11:15:06 AM5/15/18
to Gremlin-users
Hi,I was trying to find an edge through two vertices.

when i use groovy-gremlin,it's work:
gremlin> g.V().has("bulkLoader.vertex.id",1).bothE().where(otherV().has("bulkLoader.vertex.id",2))
==>e[5j7-cns-2dx-ftk][16408-call->20504]



but when i use gremlinpython,it doesn't work:
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
from gremlin_python.process.traversal import *

#pprint.pprint(g.V().has("bulkLoader.vertex.id",'1').bothE().otherV().toList())
pprint.pprint(g.V().has("bulkLoader.vertex.id",'1').bothE().where(otherV().has("bulkLoader.vertex.id",'2')))

Traceback (most recent call last): File "/home/shenqiqing/graphdb/janusgraph-0.2.0-hadoop2/py/test_gremlin.py", line 40, in <module> pprint.pprint(g.V().has("bulkLoader.vertex.id",'1').bothE().where(otherV().has("bulkLoader.vertex.id",'2'))) NameError: name 'otherV' is not defined

 it's confused me..

Stephen Mallette

unread,
May 15, 2018, 1:46:17 PM5/15/18
to Gremlin-users
otherV() is an anonymous traversal:


it is spawned from the double underscore class so either reference it directly:

g.V().has("bulkLoader.vertex.id",'1').bothE().where(__.otherV().has("bulkLoader.vertex.id",'2'))

or establish it as a function:

otherV = __.otherV
g.V().has("bulkLoader.vertex.id",'1').bothE().where(otherV().has("bulkLoader.vertex.id",'2'))


--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/06fc62a6-8d93-4032-8018-5d3f98fbfc7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ken.gri...@gmail.com

unread,
May 15, 2018, 9:39:56 PM5/15/18
to Gremlin-users
thanks for your reply ;) It works.

在 2018年5月16日星期三 UTC+8上午1:46:17,Stephen Mallette写道:
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages