Calling super() is easier

The simpler call to super(), without any arguments, will save you some typing in Python 3:

Python 2

Python 3

class CoolMixin(object):   
 
    def do_it(self):   
        return super(CoolMixin,    
                  self).do_it()   
class CoolMixin:    def do_it(self):        return super().do_it()

 

Specifying the class name and instance is optional, thereby making your code DRY and less prone to errors while refactoring.

Get Django Design Patterns and Best Practices - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.