如何在Gremlin-Python中使用“ neq”?

时间:2018-12-03 06:30:09

标签: python gremlin

我有一个 Gremlin查询,该查询可从Gremlin控制台运行

g.V("p1").as("this").out("ContributedTo").in("ContributedTo").where(neq("this")).groupCount()

我想通过Python脚本使用它

from __future__ import print_function  # Python 2/3 compatibility

from gremlin_python import statics
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

graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection('wss://neptunedbcluster.neptune.amazonaws.com:8182/gremlin','g'))

g.V('p1').as_('this').out('ContributedTo').in_('ContributedTo').where(__.neq('this')).groupCount()

我收到一个错误

AttributeError: type object '__' has no attribute 'neq'

我应该如何在Python中表达Gremlin'neq'?

1 个答案:

答案 0 :(得分:3)

neqP类的一部分,所以我应该导入并使用它

from __future__  import print_function  # Python 2/3 compatibility

from gremlin_python import statics
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.traversal import P

from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection

graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection('wss://neptunedbcluster.neptune.amazonaws.com:8182/gremlin','g'))

g.V('p1').as_('this').out('ContributedTo').in_('ContributedTo').where(P.neq('this')).groupCount()