[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Python coding style
From: |
Han-Wen Nienhuys |
Subject: |
Re: Python coding style |
Date: |
Thu, 2 Jul 2020 09:05:46 +0200 |
On Wed, Jul 1, 2020 at 2:03 PM Jean Abou Samra <jean@abou-samra.fr> wrote:
> The Contributor's Guide (10.5.1) clearly states that "Python code should
> use PEP 8". So, I'd like to be sure everyone agrees on the following points
> which are part of applying this PEP:
to me it's a no-brainer to introduce automatic formatting. I don't
really care what standard it enforces, as long as it is automated.
> - Use `string` instead of `str` as an identifier − `str` being a
> built-in type
> already.
This would be a good rule to follow if the Python team doesn't keep
adding identifiers to the top level scope. For example, in other
projects I had a lot of code become non-compliant overnight when
Python decided that binary formatting of number is worthy of the
toplevel identifier 'bin'.
> Any thoughts?
We can take it one bit at a time. In particular, if you can provide a
recipe that would reformat diffs, I can integrate that in my
pre-commit hook, so all new code is compliant.
You can also do a global cleanup. We have done this in the past, but
it has the disadvantage that it makes history (eg. git-blame) harder
to read.
--
Han-Wen Nienhuys - hanwenn@gmail.com - http://www.xs4all.nl/~hanwen