Skip to content

Latest commit

 

History

History
24 lines (14 loc) · 592 Bytes

bad-classmethod-argument.md

File metadata and controls

24 lines (14 loc) · 592 Bytes

Pattern: cls not as first argument of classmethod

Issue: -

Description

The first argument of a class method is a reference to the current class. It is usually called cls. The cls name is used to easily differentiate class methods from instance methods.

Example of incorrect code:

    def from_httplib(ResponseCls, r, **response_kw):

Example of correct code:

    def from_httplib(cls, r, **response_kw):

Further Reading