Question

I have a function that utilizes both a default parameter and *args:

def greeting(name, *args, exclamation='yo!'):
    for arg in args:
        print(name, arg, exclamation)

This seems to work fine. However, when I check it with flake8, it returns:

1 col 38| E901 SyntaxError: invalid syntax

I am stickler for both following correct practice and having my checks clear. Am I doing this wrong? Is a different method standard?

Était-ce utile?

La solution

As iCodez guessed, this was the result of unintentionally using a version of flake8 designed for Python 2.x. Installing the Python 3 version with sudo pip-3.2 install flake8 solved the problem.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top