0

Possible Duplicate:
python 'self' explained

Ok So programming in python, and just started using classes. Now is it that "self" keeps the information going instead of being passed or taken by the garbage collector?

I searched around and came to some... interesting things, but I'm not sure if I'm understanding it correctly though.

Community
  • 1
  • 1
ZenOokami
  • 212
  • 2
  • 4
  • 12
  • `self` is just the [standardized name] of the first parameter in a method. Python passes in the "receiver" (the object which has said method) on each method invocation as the first argument. The GC and object reachability is another issue entirely. –  Dec 08 '11 at 23:57
  • The listed "duplicate" does not address this question. Although, I am sure there are other duplicates. –  Dec 08 '11 at 23:59
  • It looks like an exact duplicate mainly because the title is poor. – Michael Hoffman Dec 09 '11 at 00:07

1 Answers1

3

The self in Python is equivalent to the this pointer in C++ and the this reference in Java and C#.

Cat Plus Plus
  • 125,936
  • 27
  • 200
  • 224
Markel Mairs
  • 742
  • 2
  • 10
  • 28