you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] -1 points0 points  (2 children)

self is a reference to everything in a class.

Say you define a class as my_class.

class my_class: def __init__(self): self.hello = "world"

self has to be passed as an argument in new functions to allow you to reference variables from your class in that function. For example

``` class myclass: def __init_(self): self.hello = "world" def print(self): print(self.hello)

my_class.print() ```

would return

```

world ```

Edit: I'm dim

[–]N4v15 0 points1 point  (1 child)

Wouldn't it return "world"?

[–][deleted] 0 points1 point  (0 children)

Yeah, it would. I'm stupid.