Search code examples
pythonmethodscode-organization

How should I arrange methods in a class in Python?


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.


Solution

  • I use two strategies:

    • an editor that can fold the code so you don't have to see all of it.
    • I split the big classes into smaller ones where each does only one thing and then build my app from those small blocks.