> Nope, a class method take the class as first argument and is supposed to
return an instance of said class

Just so we don't confuse Rudi, a @classmethod is like a regular method,
except that it doesn't have access to its instance. There are no
expectation or restrictions on what it returns.

class MyClass(object):
  def regular_method(self):
    return self

  @classmethod
  def class_method(cls):
    return cls

myclass1 = MyClass()
myclass2 = MyClass()

assert myclass1.regular_method() != myclass2.regular_method()
assert myclass2.class_method() == myclass2.class_method()
​

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAkM4%3DrH%2By14JmsiZXDFTBZNxT30wmc5VvvQo-DhZ6EPg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to