Dear Python developers, PEP 8 says: "Always use self for the first argument to instance methods. Always use cls for the first argument to class methods.” But what about metaclasses? PEP 3115 seems to suggest `cls`, and so do many Python books, however tools such as flake8 don’t seem to like it. Is there a consensus opinion, and should PEP 8 be updated? Kind regards, Pim Schellart
I think it should be `cls` and flake8 etc. should be fixed. On Mon, Jan 29, 2018 at 11:34 AM, Pim Schellart <p.schellart@princeton.edu> wrote:
Dear Python developers,
PEP 8 says:
"Always use self for the first argument to instance methods.
Always use cls for the first argument to class methods.”
But what about metaclasses? PEP 3115 seems to suggest `cls`, and so do many Python books, however tools such as flake8 don’t seem to like it. Is there a consensus opinion, and should PEP 8 be updated?
Kind regards,
Pim Schellart _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/guido% 40python.org
-- --Guido van Rossum (python.org/~guido)
Coincidentally, I changed this in flake8's pep8-naming plugin about a month ago[1], although the change has not yet made it into a release. [1]: https://github.com/PyCQA/pep8-naming/pull/47 On Mon, Jan 29, 2018 at 11:53 AM, Guido van Rossum <guido@python.org> wrote:
I think it should be `cls` and flake8 etc. should be fixed.
On Mon, Jan 29, 2018 at 11:34 AM, Pim Schellart <p.schellart@princeton.edu
wrote:
Dear Python developers,
PEP 8 says:
"Always use self for the first argument to instance methods.
Always use cls for the first argument to class methods.”
But what about metaclasses? PEP 3115 seems to suggest `cls`, and so do many Python books, however tools such as flake8 don’t seem to like it. Is there a consensus opinion, and should PEP 8 be updated?
Kind regards,
Pim Schellart _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/guido%40p ython.org
-- --Guido van Rossum (python.org/~guido)
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/ jon%40indelible.org
participants (3)
-
Guido van Rossum
-
Jon Parise
-
Pim Schellart