0

How many formal parameters does

def __init__(self, name):

have?

One or two?

Is self counted as formal parameter?

If yes/no can anyone explain it to me?

Tonechas
  • 13,398
  • 16
  • 46
  • 80
  • What's your definition of a "formal parameter" it is an explicit argument and it is only convention that we use `self`, if could be called anything. – AChampion Dec 12 '16 at 03:12
  • Well then what is an explicit argument ? I want to know how it works. – Utsav Bhattarai Dec 12 '16 at 03:29
  • Is this what you are looking for? http://stackoverflow.com/questions/1984104/how-to-avoid-explicit-self-in-python – jwpfox Dec 12 '16 at 06:37
  • 1
    Formal parameter is not a precise term - therefore question is unclear. – Łukasz Rogalski Dec 12 '16 at 06:39
  • _I want to know how it works._ Why don't you ask how _lack_ of parameter is other languages works? Does result of function call depends on previous state of object? Yes it does. So why not make it explicit and pass it as a argument? `__init__` is slightly trickier, since previous state is an _empty_ state, but point still stands. – Łukasz Rogalski Dec 12 '16 at 06:46
  • Check [What is the purpose of self?](http://stackoverflow.com/questions/2709821/what-is-the-purpose-of-self) it contains some good explanations – user2314737 Dec 19 '16 at 09:14

0 Answers0