I am running Gremlin-Pyton in a Jupyter notebook and for some reason the following does not work:
g.V().group().by().by(bothE().count())
I keep getting the error:
NameError: name 'bothE' is not defined
If you followed the 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
then bothE
is available as __.bothE
.
The methods in the __
namespace can be added to your notebook globals with:
>>> statics.load_statics(globals())
so you can access bothE
directly without a prefix.
Quoting from the documentation:
Moreover, by importing the statics of Gremlin-Python, the class prefixes can be omitted.
>>> statics.load_statics(globals())
and
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]]
Caveat: I am not a Gremlin-Python user nor is it practical for me to install Gremlin to verify the above completely. I based this on reading the documentation and a scan of the project source code.