Why should it be dirty to define methods after init? Think of it this way:
When you define
class MyClass(object):
def __init__(self):
self.something = whatever
self.do_something_else()
def do_something_else(self):
...
__init__- this is the method of your class MyClass, like do_something; this is only the first class method that will be called when the instance is created MyClass. So, first put __init__not only ordinary, but also logical.
Your method do_something_elseshould not be defined first, because you use it in __init__. In terms of MyClass, this is a method similar to another. When you create your instance myclass=MyClass()is do_something_elsealready defined ...
source
share