Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dc45dd3

Browse files
author
Mark Pilgrim
committed
clarification
1 parent 12ec7c2 commit dc45dd3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

iterators.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ <h3 id=init-method>The <code>__init__()</code> Method</h3>
8585

8686
<p>The first argument of every class method, including the <code>__init__()</code> method, is always a reference to the current instance of the class. By convention, this argument is named <var>self</var>. This argument fills the role of the reserved word <code>this</code> in <abbr>C++</abbr> or Java, but <var>self</var> is not a reserved word in Python, merely a naming convention. Nonetheless, please don&#8217;t call it anything but <var>self</var>; this is a very strong convention.
8787

88-
<p>In the <code>__init__()</code> method, <var>self</var> refers to the newly created object; in other class methods, it refers to the instance whose method was called. Although you need to specify <var>self</var> explicitly when defining the method, you do <em>not</em> specify it when calling the method; Python will add it for you automatically.
88+
<p>In all class methods, <var>self</var> refers to the instance whose method was called. But in the specific case of the <code>__init__()</code> method, the instance whose method was called is also the newly created object. Although you need to specify <var>self</var> explicitly when defining the method, you do <em>not</em> specify it when calling the method; Python will add it for you automatically.
8989

9090
<p class=a>&#x2042;
9191

0 commit comments

Comments
 (0)