[Tutor] Python 3 only: Better to use implicit or explicit "object" in class statements?
Cameron Simpson
cs at cskk.id.au
Sun Jun 7 22:15:32 EDT 2020
On 07Jun2020 12:51, boB Stepp <robertvstepp at gmail.com> wrote:
>prefer being explicit with the latter. I note that pylint prefers
>omitting
>"(object)", calling it "useless-object-inheritance".
My lint script runs pylint with these items disabled:
pylint_disable=bad-whitespace,bad-indentation,bad-continuation,invalid-name,useless-object-inheritance
Now, I might start stripping these back some more since I autoformat
code more vigorously these days. But these complaints caused more noise
than their cleanup warranted. For me.
>I realize that if I am trying to write code compatible with both Python 2
>and 3 that I need to explicitly inherit from "object".
>
>So, for Python 3 only development is there any consensus? Are there any
>real arguments for being "explicit" with inheriting from "object"? I have
>to say that I have not yet found the allusion to Zen to be explicit not
>convincing.
If I'm writing shiny new modules (thus, generally for Python 3 only
unless I have some special purpose in mind), I omit the (object).
When maintaining legacy modules which might still be in play for Python
2 programmes, I still use (object). because I don't need to break such
modules gratuitously.
Cheers,
Cameron Simpson <cs at cskk.id.au>
More information about the Tutor
mailing list