4

I'm trying to follow Aerospike's Python Documentation here, but it seems that it has a syntax error?

def print_result((key, metadata, record)):
    print(key, metadata, record)

Anyone who has a better idea on how to query data using Python with Aerospike?

  • 2
    BTW, typically it is useful to share the reported error when asking how to resolve that error. – kporter Dec 05 '19 at 07:01

1 Answers1

4

I think there was an error when translating this doc from python 2 to python 3. Now it is invalid for both. I've raised the issue to the maintainer when you posted this issue on our forums.

For python 2, you only need to remove the parenthesis around the print statement or import print_function from __future__.

from __future__ import print_function

def print_result((key, metadata, record)):
    print(key, metadata, record)

Python 3 removed support for tuple parameter unpacking (PEP 3113). So to fix this for python 3 you just need to remove the tuple parameter unpacking:

def print_result(args):
    key, metadata, record = *args
    print(key, metadata, record)
kporter
  • 2,684
  • 17
  • 26