-1

method in class of M2DET published

Let's see a code sentence def consturct_modules(self,):.

I have a simple question about why this method defines (self) as (self,).

It seems to me that (self) is proper form.

What is the difference?

Flux
  • 7,901
  • 5
  • 33
  • 76
ih s
  • 71
  • 7

3 Answers3

2

No difference in terms of function. Trailing comma in function argument lists is allowed starting from Python 3.6. See: https://bugs.python.org/issue9232

In terms of style, the trailing comma is not recommended in this particular case. See: Should I add a trailing comma after the last argument in a function call?

Flux
  • 7,901
  • 5
  • 33
  • 76
1

The trailing comma makes no difference in parameter lists (though it is a syntax error in Python 3.5 and earlier).

For multi-line parameter lists, I prefer to have trailing commas on each line to make diffs smaller and more uniform.

AKX
  • 123,782
  • 12
  • 99
  • 138
1

There is no difference between (self) and (self,).

The main advantages are that it makes multi-line lists easier to edit and that it reduces clutter in diffs.

Check this link :- Why are trailing commas allowed in a list?

Akhil Pathania
  • 622
  • 2
  • 5
  • 15