4

I am using this api.. whose function call looks like:

g.vertices.index.lookup(identifier="value")

Now note that idenitifier is a variable which I have not defined but is resoluted by api and value is a string.

Something similar happens in pymongo api: http://api.mongodb.org/python/current/tutorial.html

db = client.test_database

is equal to

db = client["test_database"]

test_database in first case, even though user hasnt defined that variable.. but is understood by mongo that in my datastore, do i have a database called test_database or not..

Now, the issue I have is this: I have a colon in my datastore..

Which is to say it is like:

g.vertices.index.lookup(bad:identifier="value")

See.. the colon in the query..

And this api doesnt have that mongo type dictionary implementation..

I know, I should resolve this as in why I am getting this colon.. but this is what I am stuck at right now..

And the issue is because of that colon, I get

g.vertices.index.lookup(bad:identifier="value")
                           ^
SyntaxError: invalid syntax

How do i resolve this

frazman
  • 32,081
  • 75
  • 184
  • 269
  • 2
    Does it work for you if you try: `g.vertices.index.lookup(**{'bad:identifier':"value"})` (I'm not sure what this API is... nor how argument unpacking would work in this case)... – ely Feb 05 '14 at 20:28
  • heh that was my solution :P – Joran Beasley Feb 05 '14 at 20:28

2 Answers2

8
g.vertices.index.lookup(**{"bad:identifier":"value"})

may work ... this is known as unpacking keyword arguments

Joran Beasley
  • 110,522
  • 12
  • 160
  • 179
2

In Bulbs, index.lookup(key=value) is just syntactic sugar for index.lookup(key, value) so you could simply do this:

>>> g.vertices.index.lookup("bad:identifier", "value")

You didn't indicate which graph database server you are using (Neo4j Server, Rexster, or Titan), but the syntax is the same for each. See...

espeed
  • 4,754
  • 2
  • 39
  • 51