1

My code is:

if any(s in attrs["show"] for s in ("Apple Mac OS","Intel Mac OS")):

the error is:

 if any(s in attrs["show"] for s in ("Apple Mac OS","Intel Mac OS")):
                            ^
 SyntaxError: invalid syntax

I could run the same script successfully on one machine, then I just copied it to another machine, it returns this error, really don't know why

1
  • Could you share a bit more code and your python version? Commented Aug 3, 2012 at 14:45

1 Answer 1

5

You have an older version of Python on the machine that won't run it. Like, a really old version; this feature was added in Python 2.4, I believe.

Sign up to request clarification or add additional context in comments.

2 Comments

Python 2.3 or earlier; python 2.4 gives a NameError for any instead.
2.4 according to wikipedia ... The expression could be turned into a list-comp ... (that goes back to 2.0) (reference: en.wikipedia.org/wiki/List_comprehension#Python )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.