2

I am currently working on getting started with Janus Graph and Gremlin-Python. I am going through the following example:

https://old-docs.janusgraph.org/latest/connecting-via-python.html

In part 2 of the example, there is some strange syntax I have never seen in Python before:

from gremlin_python.process.graph_traversal import __

I understand how imports work and the from as well as import... but what on earth is import ___??

My guess would be that it imports private functions... but I don't see any private functions in use in the example. So what is this doing?

Snoop
  • 1,046
  • 1
  • 13
  • 33
  • `__` is just a name like any other. There's nothing particularly special going on here, aside from the unusual name. – Brian61354270 Apr 07 '21 at 17:28
  • @Brian really? I thought it would be like some wild-card functionality or something. Good to know. – Snoop Apr 07 '21 at 17:32
  • Related question for future readers: [What is the purpose of the single underscore “_” variable in Python?](https://stackoverflow.com/questions/5893163/what-is-the-purpose-of-the-single-underscore-variable-in-python/5893946) – Brian61354270 Apr 07 '21 at 17:42

1 Answers1

2

The identifier __ has no special meaning in Python, aside from not being imported by default when using from module import * like all identifiers of the form _*. See the Python documentation on Reserved Identifiers.

Brian61354270
  • 8,690
  • 4
  • 21
  • 43
  • 1
    This is correct, I looked through the source code and found the class __ in there. This is some sort of implementation of a language integrated query, where the __ can take on the form of another class at run time. – Snoop Apr 07 '21 at 17:41