Python indentation (3 spaces)

Peter J. Holzer hjp-python at hjp.at
Sun Nov 11 13:15:33 EST 2018


On 2018-10-25 12:59:18 +0200, Antoon Pardon wrote:
> On 20-10-18 14:38, Peter J. Holzer wrote:
> > On 2018-10-16 06:37:56 +1100, Chris Angelico wrote:
> >> On Tue, Oct 16, 2018 at 6:34 AM Peter J. Holzer <hjp-python at hjp.at> wrote:
> >>> On 2018-10-15 14:12:54 +0200, Antoon Pardon wrote:
> >>>> On 13-10-18 09:37, Peter J. Holzer wrote:
> >>>>> On 2018-10-09 09:55:34 +0200, Antoon Pardon wrote:
> >>>>>> On 08-10-18 19:43, Peter J. Holzer wrote:
> >>>>>>> In practice it doesn't work in my experience. There is always someone in
> >>>>>>> a team who was "just testing that new editor" and replaced all tabs
> >>>>>>> with spaces (or vice versa) or - worse - just some of them.
> >>>>>> Isn't that caugth in the process of commiting to version control?
> >          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >          Underlined to emphasize the context.
> >
[...]
> >> If there's a change, it shows up. If there's no change, it doesn't show up.
> >>
> >> Ergo, if you accidentally replace a tab with spaces, it's a change,
> >> and it shows up.
> > If any change "shows up" (i.e., is rejected by the pre-commit hook of
> > your version control system) you can't change anything which makes using
> > a version control system rather pointless.
> 
> I just do a diff between the local version and the "latest" commited version.
> If lines show up in the diff that don't looked changed, then there is a high
> probablity someone replaced tabs with spaces. (Especially if there are a lot
> of those lines.)

I misunderstood what you meant by "the process of commiting to
version control". For me this is the series of steps the version control
software (e.g. git) performs when you issue its commit command,
including executing pre-commit and post-commit hooks. This process is
non-interactive and either succeeds or not.

You apparently include some actions that the person committing the
changes does manually before actually issuing the commit command, e.g.
checking diffs for plausibility.


> Maybe for some reason you don't consider this MO as easily catching spaces that
> accidently replaced tabs. But it is easy enough for me.

It may or may not be viable, depending on how disciplined your
colleagues are (the question is not: "Do you do this?", but "does
everyone on your team always do it?").

        hp

-- 
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | hjp at hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20181111/5ba35787/attachment.sig>


More information about the Python-list mailing list