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


Groups > comp.lang.python > #74847

Re: What's the proper style for a library string function?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.015
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; '"""': 0.07; 'important,': 0.07; 'code"': 0.09; 'consistency': 0.09; 'pep': 0.09; 'subject:string': 0.09; 'terms,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'overriding': 0.16; 'pep8': 0.16; 'rule.': 0.16; 'subject:library': 0.16; 'ignore': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'module': 0.19; 'examples': 0.20; 'rules': 0.22; 'cc:addr:python.org': 0.22; 'apply.': 0.24; 'decide': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; "doesn't": 0.30; 'important.': 0.30; 'message-id:@mail.gmail.com': 0.30; 'gives': 0.31; 'code': 0.31; 'follows': 0.31; 'style': 0.33; 'subject:the': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'project': 0.37; 'sometimes': 0.38; 'called': 0.40; 'how': 0.40; 'even': 0.60; 'most': 0.60; 'new': 0.61; "you're": 0.61; 'more': 0.64; 'details': 0.65; 'within': 0.65; '20,': 0.68; 'applying': 0.72; 'jul': 0.74; 'answer:': 0.84; 'conflicts': 0.84; 'conscience': 0.84; 'guideline': 0.84; 'crucial': 0.91; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=tUHPAY45rk0hdVdmBZJCFwYmMR2lex1cogQsF531yBM=; b=l9DUQaULt/oTHFqWe7jiWiEFXuE9knqgaweu1ThVmhkSM1A3gnh6fuf42XQotOapNd 3rbjkNLOSBCo8sSmimXMMTx+iP95Zza+AcmJCGuS5r9q8HK05Kyb9FKsO46ldHU8bUIi Iwgu+rEOpSZ3/gKOYgqCy7Wbf100rGcNsYH43HaRPCzVrQRCvhrR6ofuXaTjfdsPwB/R Ja6BUvjgcGEYVrHqbUx8hXn2C0ExsyFqZMF8jVJdOofvkcG1Ojhv7O7//fRIQuiOCK+Q gq52evJCCN2rMXFNL6/fVQgCoj4RoObv0I2etpDHCDJFC0d9uRhmqKwbsp/iQOZtqBuk p60g==
MIME-Version 1.0
X-Received by 10.221.66.67 with SMTP id xp3mr1066843vcb.44.1405816916549; Sat, 19 Jul 2014 17:41:56 -0700 (PDT)
In-Reply-To <53CABB99.8020009@gmail.com>
References <53CAAD27.9010207@cdreimer.com> <53CABB99.8020009@gmail.com>
Date Sun, 20 Jul 2014 10:41:56 +1000
Subject Re: What's the proper style for a library string function?
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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.12072.1405816923.18130.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1405816923 news.xs4all.nl 2887 [2001:888:2000:d::a6]:44529
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:74847

Show key headers only | View raw


On Sun, Jul 20, 2014 at 4:40 AM, Wojciech Giel <wojtekgiel@gmail.com> wrote:
> You might look into PEP8 "Style Guide for Python Code" it will give you
> recommendation how to write a code. among other gives most sensible answer:
>  "Consistency within a project is more important. Consistency within one
> module or function is most important...... When in doubt, use your best
> judgment. Look at other examples and decide what looks best."

But perhaps the most crucial part of PEP 8 is up in the introductory text:

"""
But most importantly: know when to be inconsistent -- sometimes the
style guide just doesn't apply.
...
Some other good reasons to ignore a particular guideline:

1. When applying the guideline would make the code less readable, even
for someone who is used to reading code that follows this PEP.
"""

This is a very New Testament style of guidebook: your conscience is
very important, the details of the rules are subordinate to the
overriding principle of readability. In Dungeons & Dragons terms,
you're called to be a paladin with an emphasis on Good where it
conflicts with Lawful. This is PEP 8's anti-bureaucracy rule.

ChrisA

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


Thread

Re: What's the proper style for a library string function? Chris Angelico <rosuav@gmail.com> - 2014-07-20 10:41 +1000

csiph-web