What is the proper or standard way to layout a class. If a class where to have attributes, methods, private attributes, private methods, class property (methods), and class methods. I am done 99% of my coding procedurely and beyond working with ORM haven't focused to much on OOP. I am changing that in a current project and was just curios what the standard way of organizing your classes was.
Class MyClass():
attr1 = value1
attr2 = value2
_attr3 = value3
def __init__(self):
do some stuff
def do_something(self):
do some more stuff
def __do_something_else(self):
more stuff
@property()
def attr4(self):
return do_some_stuff_else()
@classmethod()
def generator_a_bunch_of_these(cls):
do_some_more_things
attr1
,attr2
and_attr3
) is often a very bad idea. Folks who come from languages with static declarations are sometimes confused by this and think that these class-level attributes somehow important. Also, 80% of the time, you want@staticmethod
not@classmethod
.