> But is it that bad to use class just to organize your "themes"?

There's no such a thing as good or bad, there are many shades of gray in
between, but using that pattern forces to instantiate the class just to use
one of its methods, which is inconvenient in any scenario except
sub-classing. It's important to give a decent interface and not force the
user of your library/framework to subclass in order to achieve even the
most common use cases (e.g. imagine if pymel enforces you to subclass a
PyNode in order to do anything, it would be _very_ inconvenient).


> Is this why @classmethods are used? to avoid creating having to create
the object?

Nope, a class method take the class as first argument and is supposed to
return an instance of said class, so you can do checks before and after
instantiate the class (or even cancel), it's typically used to implement
convenient constructors (i.e. QInputDialog's
getDouble/getInt/getItem/getText).

If you want to define a method not requiring an instance (aka self) or a
class (typically notated as cls) as first argument, you can decorate the
method as staticmethod, but at that point it's probably a good idea to ask
yourself why not keep it simpler and use a simple function (said that,
there are cases where it's convenient to use static methods, but usually
the KISS principle applies on top of everything).


Best regards,
Cesar

-- 
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/CAPamJi9dvrbcW6j-XSA84YF2bNviXWPEAByxHMTezP8fcL1%2B3w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to