4 Respostas
+ 3
self - is used to reference current object (instead of keywords like in some other languages). It's just a variable, so you can change its name, but self - is a standard one
+ 4
In Python you can have 1 constructor (function with name __init__) that takes self reference and arguments:
def __init__(self, ...)
You create fields just by assigning a value to them in the constructor:
def __init__(self):
self.x = 5
In Java fields are part of class structure
0
why we every time write self keyword when creating constructor or any function
0
ok