Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #74225

Re: PEP8 and 4 spaces

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'programmer': 0.03; 'resulting': 0.04; 'argument': 0.05; 'true,': 0.05; 'stops': 0.07; '*is*': 0.09; 'character,': 0.09; 'default.': 0.09; 'editor.': 0.09; 'implemented.': 0.09; 'override': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'semantic': 0.09; 'spaces': 0.09; 'assume': 0.14; 'useful,': 0.14; '"a"': 0.16; '"default': 0.16; '*only*': 0.16; 'being,': 0.16; 'carriage': 0.16; 'character.': 0.16; 'command.': 0.16; 'default),': 0.16; 'defaults,': 0.16; 'different,': 0.16; 'discussion.': 0.16; 'distinct': 0.16; 'editor,': 0.16; 'expecting': 0.16; 'finney': 0.16; 'foot': 0.16; 'multiples': 0.16; 'newlines': 0.16; 'non-default': 0.16; 'of)': 0.16; 'preferences,': 0.16; 'processor,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'renders': 0.16; 'semantics': 0.16; 'tab': 0.16; 'tabs': 0.16; 'undesirable': 0.16; 'width,': 0.16; 'wrote:': 0.18; 'appears': 0.22; 'code,': 0.22; 'putting': 0.22; 'header:User-Agent:1': 0.23; 'preferences': 0.24; 'text,': 0.24; 'text.': 0.24; 'looks': 0.24; 'right.': 0.26; '(for': 0.26; 'header:X-Complaints-To:1': 0.27; 'point': 0.28; 'specifically': 0.29; 'fixed': 0.29; 'character': 0.29; 'instruction': 0.29; "doesn't": 0.30; 'characters': 0.30; 'said,': 0.30; 'along': 0.30; "i'm": 0.30; '(which': 0.31; 'code': 0.31; 'url:wiki': 0.31; 'aligned': 0.31; 'are.': 0.31; 'convince': 0.31; "d'aprano": 0.31; 'font': 0.31; 'horizontal': 0.31; 'keys': 0.31; 'steven': 0.31; 'url:wikipedia': 0.31; 'wright': 0.31; 'writes:': 0.31; 'probably': 0.32; 'handled': 0.32; 'themselves': 0.32; 'regular': 0.32; 'text': 0.33; '(e.g.': 0.33; 'addresses': 0.33; 'device': 0.34; 'sense': 0.34; 'display': 0.35; 'editor': 0.35; 'no,': 0.35; 'but': 0.35; 'there': 0.35; 'are,': 0.36; 'sequence': 0.36; 'next': 0.36; 'url:org': 0.36; 'should': 0.36; 'starting': 0.37; 'ben': 0.38; 'convention': 0.38; 'feed': 0.38; 'to:addr:python-list': 0.38; 'fact': 0.38; 'rather': 0.38; 'itself': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'received:org': 0.40; 'space': 0.40; 'how': 0.40; 'number,': 0.60; 'hope': 0.61; 'affect': 0.61; 'recipients': 0.61; 'new': 0.61; 'skip:* 10': 0.61; 'such': 0.63; 'more': 0.64; 'different': 0.65; 'kept': 0.65; 'talking': 0.65; 'within': 0.65; '8bit%:21': 0.69; 'default': 0.69; 'apart': 0.72; 'eight': 0.74; 'jul': 0.74; 'introduce': 0.78; '*control': 0.84; 'column.': 0.84; 'different.': 0.84; 'fired': 0.84; 'received:125': 0.84; "they'd": 0.84; 'visually': 0.84; 'mean.': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ben Finney <ben@benfinney.id.au>
Subject Re: PEP8 and 4 spaces
Date Wed, 09 Jul 2014 12:41:07 +1000
References <53B59358.2040404@tobiah.org> <CAGGBd_rOg+EX1OxryW9-6+2b6yqzzKL9xN1K7+TPSP77tJz=bQ@mail.gmail.com> <mailman.11567.1404694875.18130.python-list@python.org> <lpdbjc$qf7$1@dont-email.me> <mailman.11614.1404782560.18130.python-list@python.org> <53bbb047$0$2926$c3e8da3$76491128@news.astraweb.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host jigong.madmonks.org
X-Public-Key-ID 0xAC128405
X-Public-Key-Fingerprint 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405
X-Public-Key-URL http://www.benfinney.id.au/contact/bfinney-pubkey.asc
X-Post-From Ben Finney <bignose+hates-spam@benfinney.id.au>
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)
Cancel-Lock sha1:DKivMoB1M0kFTjWJoBDOzFhF/l8=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11671.1404873682.18130.python-list@python.org> (permalink)
Lines 103
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1404873682 news.xs4all.nl 2838 [2001:888:2000:d::a6]:53754
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:74225

Show key headers only | View raw


Steven D'Aprano <steve@pearwood.info> writes:

> On Tue, 08 Jul 2014 11:22:25 +1000, Ben Finney wrote:
>
> > A group of (a particular amount of) U+0020 characters is visually
> > indistinguishable from a U+0009 character, when the default semantics
> > are applied to each.
>
> Hmmm. I'm not sure there actually *is* such a thing as "default 
> semantics" for tabs.

It was likely never standardised, but yes, default semantics are long
established for the HT (Horizontal Tab) control code in a text stream
<URL:https://en.wikipedia.org/wiki/Tab_key#Tab_characters>.

The default semantics are that an HT (Horizontal Tabulation) control
code is an instruction to introduce enough horizontal space such that
the following character appears at the next multiple-of-8 column. These
semantics assume a fixed character width, which is itself a default
semantic of the display of computer text; variable-width is a deviation
from the default.

> If you look at a tab character in a font

I'm not talking about glyphs (for a control code, there isn't much sense
talking about a default glyph), I'm talking about the default semantics
of how they affect display.

> But if you look at it in a text editor, it will probably look like
> eight spaces, unless it looks like four, or some other number, and if
> you look at it in a word processor, it will probably look like a "jump
> to the next tab stop" command.

Right. Programs that conform to the established default semantics for an
HT (U+0009) code point will shift to the next tab stop to display the
following character. Tab stops themselves are, in fixed-width character
layout (which is itself the historical default), spaced apart by
multiples of 8 character columns.

> I don't think any of those things count as "default semantics".

I hope my position is clearer.

> The point being, tabs are *control characters*, like newlines and
> carriage returns and form feeds, not regular characters like spaces
> and "A" or "λ". Since "indent" is an *instruction* rather than a
> character, it is best handled with a control character.

Right. And those control codes affect display of the text, and there are
default semantics for those codes: what those control codes specifically
mean. The HT code has the default display semantic of “display the
following character at the next horizontal tab stop”.

> The solution is to use a smarter editor.

The recipient's choice of editor program is not within the control of
the author. Furthermore, it's expecting that the recipient will deviate
from the default display semantics of the text as received.

The author should write the text such that the default semantics are
useful, and/or avoid text where the default semantics are undesirable or
unreliably implemented.

In this case: If the programmer doesn't like U+0009 resulting in text
aligned at multiple-of-8 tab stops, or doesn't like the fact that
recipients may have tab stops set differently, then I don't care what
editor the author uses; they should avoid putting U+0009 into text.

That said, a smarter text editor program *can* be a solution for “I
don't like the default semantics *as displayed on my computer*”.

If a programmer wants to deviate from the defaults, and can convince
others on a rational and non-coercive basis to go along with their
non-default preferences, they all have my blessing.

If they want their preferences to override the default more broadly,
they need a better argument than “it just looks better to me”.

> Isn't this why you recommend people use a programmer's editor rather
> than Notepad?

I don't see how recommending a better editor for the *author* addresses
how the *recipient*'s device renders the text. so no, that's not a
reason why I recommend the author use a programmer's editor.

> True, but that's *only* because your editor chooses to follow the
> convention "display a LINE FEED by starting a new line" rather than by
> the convention "display the (invisible or zero-width) glyph of the
> LINE FEED". If editors were to standardise on the convention "display
> a HORIZONTAL TAB character as visibly distinct from a sequence of
> spaces" (e.g. by shading the background a different colour, or
> overlying it with an arrow) then we would not be having this
> discussion.

If things were different, they'd be different. I'm talking about default
display semantics of the U+0009 code as they are.

-- 
 \          “I used to be an airline pilot. I got fired because I kept |
  `\       locking the keys in the plane. They caught me on an 80 foot |
_o__)                    stepladder with a coathanger.” —Steven Wright |
Ben Finney

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: PEP8 and 4 spaces Ben Finney <ben@benfinney.id.au> - 2014-07-07 11:00 +1000
  Re: PEP8 and 4 spaces Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-07-07 02:28 +0000
    Re: PEP8 and 4 spaces Chris Angelico <rosuav@gmail.com> - 2014-07-07 12:50 +1000
  Re: PEP8 and 4 spaces Dan Sommers <dan@tombstonezero.net> - 2014-07-07 05:35 +0000
    Re: PEP8 and 4 spaces Ben Finney <ben@benfinney.id.au> - 2014-07-08 11:22 +1000
      Re: PEP8 and 4 spaces wxjmfauth@gmail.com - 2014-07-08 00:03 -0700
      Re: PEP8 and 4 spaces Steven D'Aprano <steve@pearwood.info> - 2014-07-08 08:48 +0000
        Re: PEP8 and 4 spaces Chris Angelico <rosuav@gmail.com> - 2014-07-08 19:05 +1000
        Re: PEP8 and 4 spaces Marko Rauhamaa <marko@pacujo.net> - 2014-07-08 12:09 +0300
          Re: PEP8 and 4 spaces Chris Angelico <rosuav@gmail.com> - 2014-07-08 20:28 +1000
            Re: PEP8 and 4 spaces Marko Rauhamaa <marko@pacujo.net> - 2014-07-08 14:13 +0300
              Re: PEP8 and 4 spaces Chris Angelico <rosuav@gmail.com> - 2014-07-08 21:37 +1000
        Re: PEP8 and 4 spaces Ben Finney <ben@benfinney.id.au> - 2014-07-09 12:41 +1000
          Re: PEP8 and 4 spaces wxjmfauth@gmail.com - 2014-07-09 01:19 -0700

csiph-web