python - What's the usage to add a comma after self argument in a class method? -


I see in that code, I saw some class methods like this:

  Class A (B): FDF method (self,): DO_something def method2 (self,): do_something_else   

Why do the authors leave the comma behind themselves, what is the purpose?

Syntactically, the comma behind but does not really mean anything, it's just a stylistic I think the Most Python programmer will leave it (which is the advice I give too), but some might like it to like it so that it is easier to add more logic later Ho.

You can also do You will see it more often with the functions that take up many default arguments:

  x = foo (arg1 = whatever, arg2 = some, arg3 = blatzimuffin,)    lst = [x, y, z,] tup = (x, y, z) tup = x, # Not too   

This is particularly good if you want to format nested stuff well:

  {"top": ["foo" , "Bar", "falcon",], "down": ["quaux",],}   

When adding things to the list, Require to Odne / edit, not 2.

Comments

Popular posts from this blog

jasper reports - How to center align barcode using jasperreports and barcode4j -

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -