How should (or is a clean way) of organising methods in Python?
I always put the __init__ method first, followed by any other __foo__ (What do you call them?) methods. But then it leads into a jumble.
I like to organize them like this:
First: Constructor (__init__)
Second: Any other __ methods
Third: Regular methods that roughly can be categorized under "get"
Fourth: Regular methods that roughly can be categorized under "set"
Fifth: Everything else (with any methods that produce anything other than a return value--ie. actually output something or save to a database--being at the very end of this fifth category)
If you follow that pattern consistently, your eye gets used to it and it becomes easy to navigate. Of course, preferences like this vary from person to person.
I use two strategies:
I'm not sure if there is an official standard, but I always put the __init__ method first, followed by my own methods, followed by any built ins that I plan on implementing (__str__,__eq__, etc). I try to group methods by similar functionality and order built-ins the same throughout my classes.
__names) are what you're looking for. Before asking, you should bookmark the Python language reference and check there first.