I avoid classes in Python. Am I bad?

He makes several good points, but it's oversimplified IMO.

For example, his point about a class that has "two methods, one of them __init__() is really just a function".

Well, if you think about it, that's kind of what a class-based view is in Django:

``` class View: def init(self, args, *kwargs): ...

def dispatch(self, request, *args, **kwargs):
    return HttpResponse()

```

There are things in dispatch that chooses a different method to call based on the HTTP method, but those methods (get() and post()) are essentially "private" -- we could just as well put all the logic in dispatch().

Does this mean we should all be writing function based views only?

I try to mostly write FBVs myself, but in reality there are benefits to making views classes. One of these benefits is the ability to inherit these classes to extend the behaviour.

/r/learnpython Thread Parent