Mr. Kennedy Mr. Kennedy - 5 months ago 11x
Python Question

Are Python function parameters enclosed in tuples or just conventional parentheses?

Are functions passed parameters enclosed in parentheses because they are handled as tuples, or just a result of f(x) convention?

i.e. is (b, a, r) a tuple here:

def foo(b, a, r):

Or, is it something more like the way parentheses are used in math equations, e.g.

>>> 3 * 2 + 1
>>> 3 * (2 + 1)


You can answer this by looking at the Python Grammar.

The relevant lines are:

funcdef: 'def' NAME parameters ['->' test] ':' suite
parameters: '(' [typedargslist] ')'

So in your example, the grammar would say that (b, a, r) is a typedargslist surrounded by brackets.