-
Notifications
You must be signed in to change notification settings - Fork 197
Documentation example doesn't work #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This problem is likely just an extra comma after for friend, in session.run(...) |
The comma is not extra. for friend, in session.run("MATCH (a:Person {name:'Alice'})-[:KNOWS]->(x) RETURN x"):
print('Alice says, "hello, %s"' % friend["name"]) is equivalent to: for record in session.run("MATCH (a:Person {name:'Alice'})-[:KNOWS]->(x) RETURN a, x"):
friend, = record
print('Alice says, "hello, %s"' % friend["name"])
It's use is to extract returned values like so: for a, x in session.run("MATCH (a:Person {name:'Alice'})-[:KNOWS]->(x) RETURN a,x"):
print('%s says, "hello, %s"' % (a["name"], x["name"])) instead of having to address them explicitly in the record: for record in session.run("MATCH (a:Person {name:'Alice'})-[:KNOWS]->(x) RETURN a,x"):
print('%s says, "hello, %s"' % (record["a"]["name"], record["x"]["name"])) The problem is that I believe this is a flaw in the implementation of the neo4j-python-driver/neo4j/v1/session.py Line 477 in f7c2f77
I may be wrong, I just started to evaluate this library, but I see no point in providing iteration support to fetch the already known variable names instead of the actual values. |
Fixed in #111 |
From https://neo4j.com/docs/api/python-driver/current/#example
This line:
The text was updated successfully, but these errors were encountered: