Paulo Casaretto
Paulo Casaretto

Reputation: 1027

Having a non-optional argument follow an optional argument

On this code:

def plot(div_name = "", series , options = {} )

I'm getting a syntax error:

unexpected '=', expecting ')' (SyntaxError).

Why is that? Assigning a default value to series solves the problem.

Upvotes: 2

Views: 215

Answers (1)

sepp2k
sepp2k

Reputation: 370435

You're not allowed to have optional arguments followed by non-optional arguments followed by further optional arguments. If that were allowed, it would be ambiguous whether plot(foo, bar) should be plot(foo, bar, {}) or plot("", foo, bar).

Upvotes: 5

Related Questions