python NameError 中的 gremlin 无法识别函数
gremlin in python NameError not recognising functions
我是 运行 Jupyter notebook 中的 Gremlin-Python,但出于某种原因,以下内容不起作用:
g.V().group().by().by(bothE().count())
我一直收到错误消息:
NameError: name 'bothE' is not defined
如果您关注了typical imports listed in the documentation:
>>> 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
然后 bothE
可用作 __.bothE
。
__
命名空间中的方法可以添加到您的笔记本全局变量中:
>>> statics.load_statics(globals())
因此您可以直接访问 bothE
而无需前缀。
引用文档:
Moreover, by importing the statics of Gremlin-Python, the class prefixes can be omitted.
>>> statics.load_statics(globals())
和
Finally, statics includes all the -methods and thus, anonymous traversals like .out()
can be expressed as below. That is, without the __.
-prefix.
>>> g.V().repeat(out()).times(2).name.fold().toList()
[[ripple, lop]]
警告:我不是 Gremlin-Python 用户,安装 Gremlin 来完全验证上述内容也不实际。我基于阅读文档和扫描项目源代码。
我是 运行 Jupyter notebook 中的 Gremlin-Python,但出于某种原因,以下内容不起作用:
g.V().group().by().by(bothE().count())
我一直收到错误消息:
NameError: name 'bothE' is not defined
如果您关注了typical imports listed in the documentation:
>>> 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
然后 bothE
可用作 __.bothE
。
__
命名空间中的方法可以添加到您的笔记本全局变量中:
>>> statics.load_statics(globals())
因此您可以直接访问 bothE
而无需前缀。
引用文档:
Moreover, by importing the statics of Gremlin-Python, the class prefixes can be omitted.
>>> statics.load_statics(globals())
和
Finally, statics includes all the -methods and thus, anonymous traversals like
.out()
can be expressed as below. That is, without the__.
-prefix.>>> g.V().repeat(out()).times(2).name.fold().toList() [[ripple, lop]]
警告:我不是 Gremlin-Python 用户,安装 Gremlin 来完全验证上述内容也不实际。我基于阅读文档和扫描项目源代码。