+ 1

self parameter

I want to know about self parameter in class in broader way. Can anyone tell me. Why we use self in Python and not in other languages ?

8th Feb 2022, 5:21 PM
Mahesh Umale
Mahesh Umale - avatar
2 Answers
+ 2
Richard Newman self behaves like this (java) but remember self is not a keyword, you can change self to this also. class Circle (object): def __init__(self, radius): self.radius = radius circle1 = Circle (10) change self to this: class Circle (object): def __init__(this, radius): this.radius = radius circle1 = Circle (10) in Java: class Circle { private int radius; public Circle (int radius) { this.radius = radius; } } Circle c = new Circle (10);
8th Feb 2022, 5:34 PM
AÍąJ
AÍąJ - avatar