Quantcast
Channel: What is the purpose of the `self` parameter? Why is it needed? - Stack Overflow
Viewing all articles
Browse latest Browse all 77

Answer by kame for What is the purpose of the word 'self'?

$
0
0

I like this example:

class A:     foo = []a, b = A(), A()a.foo.append(5)b.fooans: [5]class A:     def __init__(self):         self.foo = []a, b = A(), A()a.foo.append(5)b.fooans: []

Viewing all articles
Browse latest Browse all 77

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>