<div>John,</div>
<div> </div>
<div>   I agree with you and I also think the definition given on the official python site is somewhat confusing, at least for an engineer like myself.  But I'll take a stab at explaning it using what I know thus far.</div>

<div> </div>
<div>  I think to understand what a class method is you have to first understand what a class variable is.  Take this code snippet for example.</div>
<div> </div>
<div>class foo(object):</div>
<div>     x=10</div>
<div>     def __init__(self):</div>
<div>          self.x=20</div>
<div> </div>
<div>In this example if you create an instance of foo and call it f.  You can access the instance attribute x by using f.x or you can access the class variable using the notation foo.x.  These two will give you two different results.  Now lets do something a bit more interesting.</div>

<div>Say you have the following snippet.</div>
<div> </div>
<div>class foo(object):</div>
<div>     x=0</div>
<div>     def __init__(self):</div>
<div>          self.x=10</div>
<div>          foo.x+=1</div>
<div> </div>
<div>>>>f=foo()</div>
<div>>>>g=goo()</div>
<div>>>>f.x</div>
<div>10</div>
<div>>>>g.x</div>
<div>10</div>
<div>>>>foo.x</div>
<div>2</div>
<div> </div>
<div>What happened here is that the class variable foo.x is used to keep a count of the total number of instances created.  So we see that a class variable can be looked at as what "connects" the two instances in a way, so that data can be shared between instances of the same class.  This defintion may very well only apply to this case, but I think the mechanics is fundamentally the same.  <br>
</div>
<div>Keeping this in mind, lets make the jump to class methods.  When an instance of a class is created, the methods are just functions that "work on" the attributes (the variables).  Similarly, a class method is a method that works on a class variable.  For example, </div>

<div> </div>
<div>class foo(object):</div>
<div>     x=10</div>
<div>     def __init__(self):</div>
<div>          self.x=20</div>
<div>     @classmethod</div>
<div>     def change(self):</div>
<div>           self.x=15</div>
<div> </div>
<div>>>>f=foo()</div>
<div>>>>f.x</div>
<div>20</div>
<div>>>>foo.x</div>
<div>10</div>
<div>>>>f.change()</div>
<div>>>>f.x</div>
<div>20</div>
<div>>>>foo.x</div>
<div>15</div>
<div> </div>
<div>So this is my explanation for what a classmethod is.  Hope it helps.  Good luck.  </div>
<div> </div>
<div>Denis </div>
<div> </div>
<div class="gmail_quote">On Mon, Aug 23, 2010 at 2:24 AM, John Nagle <span dir="ltr"><<a href="mailto:nagle@animats.com">nagle@animats.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">On 8/22/2010 9:16 PM, James Mills wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">On Mon, Aug 23, 2010 at 1:53 PM, Paulo da Silva 
<div class="im"><br><<a href="mailto:psdasilva.nospam@netcabonospam.pt" target="_blank">psdasilva.nospam@netcabonospam.pt</a>>  wrote:<br></div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">I did it before posting ... 
<div class="im"><br>The "explanation" is not very clear. It is more like "how to use it".<br></div></blockquote><br>
<div class="im">Without going into the semantics of languages basically the<br>differences are quite clear:<br><br>@classmethod is a decorator that warps a function with<br>passes the class as it's first argument.<br>
<br>@staticmethod (much like C++/Java) is also a decorator that<br>wraps a function but does not pass a class or instance as<br>it's first argument.<br></div></blockquote><br>   That reads like something the C++ standards revision committee<br>
would dream up as they add unnecessary template gimmicks to the<br>language.<br><font color="#888888"><br>                               John Nagle</font> 
<div>
<div></div>
<div class="h5"><br>-- <br><a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br></div></div></blockquote></div><br>