Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Python question. Syntax error?
I'm new to Python and I have an example script that has a syntax error, but I can't see what's wrong. Here it is:
class SimpleGraph:
def __init__(self):
self._spo = {}
self._pos = {}
self._osp = {}
def add(self, (sub, pred, obj)):
I get a syntax error on the ( before sub. I'm running Python 3.1. Any ideas?
1 Answer
- SilentLv 71 decade agoFavorite Answer
Why do you have parentheses around the last three parameters to the add function?
If you're trying to make the function take a tuple as a parameter, you can't do it that way in Python 3. That was possible in previous versions of Python, but not anymore.
Python 3 and Python 2 are not compatible languages. If you're running Python 3, don't use example code written for Python 2; you'll just end up with a lot of confusion and things that don't work.