hi,
I understand that a @classmethod decorator allows to access a method without
creating the object. For instance
class myCLass(object):
def myMethod(self):
print "hello"
myCLass().myMethod()
myCLass.myMethod() #<< that would give an error because the object is requiered
to do so I create a @classmethod
class myCLass(object):
@classmethod
def myMethod(self):
print "hello"
myCLass.myMethod() # now it works
my question is. What is the advantage? does that make evaluation faster?
I ask all that because I am learning maya api and in an example I got :
mSelectionList = OpenMaya.MSelectionList()
OpenMaya.MGlobal.getActiveSelectionList(mSelectionList)
I am confused because I was able to use the method getActiveSelectionList()
without creating the object MGlobal. I would have wrote
mGlobal = OpenMaya.MGlogal
mGlobal.getActiveSelectionList(mSelectionList)
it is like the method getActiveSelectionList() had somehow @classmethod
do I make any sence?
thans
--
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/3bdf070b-31db-413f-8e6b-682cb2258f6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.