Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'example:': 0.03; 'operator': 0.03; 'value,': 0.04; 'assignment': 0.07; 'benefits,': 0.09; 'pay.': 0.09; 'pep': 0.09; 'rows,': 0.09; 'section,': 0.09; 'typed': 0.09; 'python': 0.11; 'assume': 0.14; '>>': 0.16; '42,': 0.16; 'aligned.': 0.16; 'assembler,': 0.16; 'code?': 0.16; 'columns': 0.16; 'other)': 0.16; 'readability': 0.16; 'rough': 0.16; 'applies': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'obviously': 0.18; 'variable': 0.18; '>>>': 0.22; '>>>': 0.24; 'align': 0.24; 'case.': 0.24; 'interpret': 0.24; 'large,': 0.24; '(or': 0.24; "i've": 0.25; '>': 0.26; 'possibly': 0.26; 'tables': 0.26; 'gets': 0.27; 'header:In-Reply- To:1': 0.27; 'tim': 0.29; 'statement': 0.30; 'message- id:@mail.gmail.com': 0.30; 'skip:( 20': 0.30; 'code': 0.31; 'easier': 0.31; 'usually': 0.31; 'aligned': 0.31; 'another.': 0.31; 'chase': 0.31; 'comparison': 0.31; 'factor': 0.31; 'once,': 0.31; 'file': 0.32; 'this.': 0.32; 'to:name:python-list': 0.33; 'table': 0.34; "i'd": 0.34; 'advice': 0.35; 'common': 0.35; 'something': 0.35; 'hundreds': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'maintained': 0.36; 'similar': 0.36; 'list': 0.37; 'easily': 0.37; 'skip:& 10': 0.38; 'to:addr:python- list': 0.38; 'does': 0.39; 'though,': 0.39; 'to:addr:python.org': 0.39; 'space': 0.40; 'read': 0.60; "you're": 0.61; 'making': 0.63; 'costs': 0.63; 'such': 0.63; 'july': 0.63; 'more': 0.64; 'skip:m 50': 0.68; 'no:': 0.84; 'occasion': 0.84; '"how': 0.91; 'edwards': 0.91; 'wanting': 0.93; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type; bh=9mSwJ+WcY57qiGpa0kAGhcPZhVglZy8n1sa6akINyDM=; b=CX2OWoQYLOhMMV9lWkxJNk9YvjkDGqDvM2OVcoV5T4svNoVfVEX8+Bc97OY7yxdYgH eKAHw0TM3JrN/fLilyUNJv7Rg9yCuszauA7WUbvlHm3yY1gcLaaTPk9jgucamiUhhvcl KCej9t2YabGpRNV4hx/h4pkJvCFKXhcCQw5ID55vR9xnwSDDrxPfekSl0h4cMLTrfRIW CGJh7GiHHvlhMz43G/iZuYkgRhkfYUUjy2eqjW7iR2Xa/ixVXfLp5M4ylTCcbg87vJNK zOxaaKLKvC+nBIb18CugU2/ZqphrUszTOcvn+8DjMOU62biRZmjDu/GVe/NzowG0CdxI n7WQ== X-Received: by 10.112.160.74 with SMTP id xi10mr1790230lbb.63.1375377732729; Thu, 01 Aug 2013 10:22:12 -0700 (PDT) MIME-Version: 1.0 Sender: joshua.landau.ws@gmail.com In-Reply-To: References: <51F6C5F5.5020201@Gmail.com> <51f6e1d8$0$30000$c3e8da3$5496439d@news.astraweb.com> <51F6ED13.5010508@Gmail.com> From: Joshua Landau Date: Thu, 1 Aug 2013 18:21:32 +0100 X-Google-Sender-Auth: 0USafCKXMZp12BvfPC-pcvmMaWg Subject: Re: PEP8 79 char max To: python-list Content-Type: multipart/alternative; boundary=001a11c3421e30ff0e04e2e6158d X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 176 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375378233 news.xs4all.nl 15879 [2001:888:2000:d::a6]:43265 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51743 --001a11c3421e30ff0e04e2e6158d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 31 July 2013 17:32, Grant Edwards wrote: > On 2013-07-31, Tim Chase wrote: > > On 2013-07-31 07:16, Joshua Landau wrote: > >> On 30 July 2013 18:52, Grant Edwards wrote: > >>> I also find intializers for tables of data to be much more easily > >>> read and maintained if the columns can be aligned. > >> > >> Why do you have tables in your Python code? > > For example: if you're writing an assembler, you usually have a table > of mnemonics/opcodes/instruction-format/addressing-modes. Why are you writing an assembler? > > I've had occasion to write things like: > > > > for name, value, description in ( > > ("cost", 42, "How much it cost"), > > ("status", 3141, "Status code from ISO-3.14159"), > > ... > > ): > > do_something(name, value) > > print(description) > > > > I interpret Grant's statement as wanting the "table" to look like > > > > for name, value, description in ( > > ("cost", 42, "How much it cost"), > > ("status", 3141, "Status code from ISO-3.14159"), > > ... > > ): > > do_something(name, value) > > print(description) > > Exactly. When you have more than about 5 columns and 10 rows, having > things aligned makes it far, far, easier to maintain. Honestly I've never had to do something like this. If it got that large, though, I'd factor it out into it's own file and possibly take the advice from others on this list by making it a CSV. That said for someone like me the very tiny frequency I'd have to do such a thing would pale in comparison to the other costs and benefits of variable with fonts. > > which does give some modest readability benefits, but at a creation > > cost I personally am unwilling to pay. > > It only gets typed once, it gets read hundreds or thousands of times. > Optimize the common case. > PEP 8, under the things-not-to-do section, says: =C2=B7 More than one space around an assignment (or other) operator to = align it with another. Yes: x =3D 1 y =3D 2 long_variable =3D 3 No: x =3D 1 y =3D 2 long_variable =3D 3 I assume similar applies here. Obviously PEP 8 isn't a rule but it's a rough stab at general consensus. --001a11c3421e30ff0e04e2e6158d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On 31 July 2013 17:32, Grant Edwards <= ;invalid@inval= id.invalid> wrote:
On 2013-07-31, Tim Chase <python.list@tim.thechases.com>= wrote:
> On 2013-07-31 07:16, Joshua Landau wrote:
>> On 30 July 2013 18:52, Grant Edwards wrote:
>>> I also find intializers for tables of data to be much more eas= ily
>>> read and maintained if the columns can be aligned.
>>
>> Why do you have tables in your Python code?

For example: if you're writing an assembler, you usually have a t= able
of mnemonics/opcodes/instruction-format/addressing-modes.
=
Why are you writing an assembler?
=C2=A0
> I've had occasion to write things like:
>
> =C2=A0 for name, value, description in (
> =C2=A0 =C2=A0 =C2=A0 ("cost", 42, "How much it cost&quo= t;),
> =C2=A0 =C2=A0 =C2=A0 ("status", 3141, "Status code from= ISO-3.14159"),
> =C2=A0 =C2=A0 =C2=A0 ...
> =C2=A0 =C2=A0 =C2=A0 ):
> =C2=A0 =C2=A0 do_something(name, value)
> =C2=A0 =C2=A0 print(description)
>
> I interpret Grant's statement as wanting the "table" to = look like
>
> =C2=A0 for name, value, description in (
> =C2=A0 =C2=A0 =C2=A0 ("cost", =C2=A0 42, =C2=A0 "How mu= ch it cost"),
> =C2=A0 =C2=A0 =C2=A0 ("status", 3141, "Status code from= ISO-3.14159"),
> =C2=A0 =C2=A0 =C2=A0 ...
> =C2=A0 =C2=A0 =C2=A0 ):
> =C2=A0 =C2=A0 do_something(name, value)
> =C2=A0 =C2=A0 print(description)

Exactly. =C2=A0When you have more than about 5 columns and 10 rows, h= aving
things aligned makes it far, far, easier to maintain.

=
Honestly I've never had to do something like this. If it got= that large, though, I'd factor it out into it's own file and possi= bly take the advice from others on this list by making it a CSV.

That said for someone like me the very tiny frequency I= 'd have to do such a thing would pale in comparison to the other costs = and benefits of variable with fonts.
=C2=A0
> which does give some modest readability benefits, but at a creation > cost I personally am unwilling to pay.

It only gets typed once, it gets read hundreds or thousands of times.=
Optimize the common case.

PEP 8, under = the things-not-to-do section, says:

=C2=A0 =C2=A0 =C2= =B7 More than one space around an assignment (or other) operator to align i= t with another.

=C2=A0 =C2=A0 Yes:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 x =3D 1
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 y =3D 2
=C2=A0 =C2=A0 =C2=A0 =C2=A0 long_variable =3D = 3

=C2=A0 =C2=A0 No:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 x =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D 1
=C2=A0 =C2=A0 =C2=A0 =C2=A0 y =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =3D 2
=C2=A0 =C2=A0 =C2=A0 =C2=A0 lon= g_variable =3D 3
=C2=A0
I assume similar applies here. Obviou= sly PEP 8 isn't a rule but it's a rough stab at general consensus.<= /div>
--001a11c3421e30ff0e04e2e6158d--