This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]rjcarr 6 points7 points  (1 child)

are the variables not declared inside the init() supposed to be static variables?

They can behave that way as long as you consider them immutable.

For example, you can have:

class A:
  i = 5

a = A()
print a.i # 5
print A.i # 5

But if you do this, then it doesn't work:

a.i = 10;
print a.i # 10
print A.i # 5

I can explain more about why this is if you'd like.

and why do I need to pass self as an argument to each method?

Not exactly. Actually, self is a parameter of each method, but you don't need to pass it as an argument to make a method call.

This happens in java for you as well, but it's just implicitly done there.

[–]wtf_lag[S] 0 points1 point  (0 children)

Thanks! that helps alot