Thank you that makes sense to me. Much more clear then the tutorial, I think so anyway. If you are learning about classes that you kinda expect MyClass to have counter in it. I might be nice to show that x.counter = 1 creates an instance that would look like (is this correct?)<br>
<br>class MyClass:<br>    """A simple example class"""<br>    i = 12345<br>    counter = 1<br>    def f(self):<br>        return 'hello world'<br><br>Thanks again<br><br>Vincent Davis<br clear="all">
<br><br><div class="gmail_quote">On Sat, May 23, 2009 at 8:24 AM, Benjamin Kaplan <span dir="ltr"><<a href="mailto:benjamin.kaplan@case.edu">benjamin.kaplan@case.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><br><div class="gmail_quote"><div><div></div><div class="h5">On Sat, May 23, 2009 at 9:13 AM, Vincent Davis <span dir="ltr"><<a href="mailto:vincent@vincentdavis.net" target="_blank">vincent@vincentdavis.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
let me add that I see that this could be right if <span style="border-collapse: collapse;">x.counter = 1 and counter need not have anything to do with MyClass but this could be more clear. </span><div><br clear="all">

Thanks<br>Vincent Davis<br>720-301-3003<br>
<br><br></div><div><div></div><div><div class="gmail_quote">On Sat, May 23, 2009 at 7:08 AM, Vincent Davis <span dir="ltr"><<a href="mailto:vincent@vincentdavis.net" target="_blank">vincent@vincentdavis.net</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<span style="border-collapse: collapse;">Section 9.3.3 says that given,</span><div><span style="border-collapse: collapse;"><br>
</span><div><span style="border-collapse: collapse;"><div>class MyClass:</div><div>    """A simple example class"""</div>
<div>    i = 12345</div><div>    def f(self):</div><div>        return 'hello world'</div><div><br></div><div>and x = MyClass()</div><div>then this</div><div><br></div><div><div>x.counter = 1</div><div>while x.counter < 10:</div>



<div>    x.counter = x.counter * 2</div><div>print(x.counter)</div><div>del x.counter</div><div><br></div><div>will print 16</div><div><br></div><div>link, <a href="http://docs.python.org/3.0/tutorial/classes.html#a-first-look-at-classes" target="_blank">http://docs.python.org/3.0/tutorial/classes.html#a-first-look-at-classes</a></div>



<div><br></div><div>I am reading this section so to learn about classes but if this is right I think I need to start over.</div><div><br></div></div><div></div></span></div></div></blockquote></div></div></div></blockquote>

</div></div><div><br>The code given is correct, though the description in the tutorial could be clearer. Basically, a class in Python is represented by a dict with strings mapping to other stuff. Internally, x.counter = 1 is just a shortcut for x.__dict__['counter'] = 1. This appears in the code as dynamically adding the variable "counter" to the instance of MyClass. Unlike in static languages, an instance variable in python doesn't need to be declared inside the class for you to use it. It also doesn't need to appear in every instance of the class.<br>

<br>The last line in the code (del x.counter) removes the "counter" key from x so that the instance variable disappears. That's how the code works "without leaving a trace".<br><br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">
<div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div><span style="border-collapse: collapse;"><div>

<br></div></span>Thanks<br>Vincent Davis<br>720-301-3003<br>
</div></div>
</blockquote></div><br>
</div></div><br></div>--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
<br></blockquote></div><br>
<br>--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
<br></blockquote></div><br>